Skip to content

Commit

Permalink
Merge pull request #74 from mottesen-cityworks/develop
Browse files Browse the repository at this point in the history
added more exception handling
  • Loading branch information
allisonmuise authored Apr 1, 2020
2 parents 1772df2 + a18396d commit 5674a2d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions CityworksConnection/connect_to_cityworks.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@

def get_response(url, params):
response = requests.post(url, params=params)
return json.loads(response.text)
try:
return json.loads(response.text)
except:
return {'ErrorMessages':'HTML returned, check {}/Errors.axd'.format(baseUrl)}


def get_cw_token(user, pwd, isCWOL):
Expand Down Expand Up @@ -153,8 +156,8 @@ def submit_to_cw(row, prob_types, fields, oid, typefields):

# Submit report to Cityworks.
url = "{}/Services/AMS/ServiceRequest/Create".format(baseUrl)

response = get_response(url, params)

try:
return response["Value"]

Expand Down Expand Up @@ -403,6 +406,8 @@ def main(event, context):
# if related tables aren't being used
except AttributeError:
pass
except KeyError:
relname = "Comments"
updated_rows = []
for record in rel_records:
try:
Expand Down

0 comments on commit 5674a2d

Please sign in to comment.