Skip to content

Commit

Permalink
Catch erroneous response during JSON parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasotocerny committed Oct 30, 2018
1 parent baca280 commit de5c113
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion exponea_python_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ def request(self, method, path, payload=None):
response = requests.request(method, url, json=payload, auth=HTTPBasicAuth(self.username, self.password))
status = response.status_code
self.logger.debug('Response status code: %d', status)
result = json.loads(response.text)
try:
result = json.loads(response.text)
except JSONDecodeError:
self.logger.error(response.text)
raise APIException(response.text)
if status == 200 and result['success']:
return result
self.logger.error(response.text)
Expand Down

0 comments on commit de5c113

Please sign in to comment.