Skip to content

Commit e8eb1e0

Browse files
vlavorininilsnolde
authored andcommitted
Added HTTP error handling in _get_body (#38)
* Update client.py Modified behaviour of _get_body in absence of a body to get: in such cases, there is actually a HTTP error which will be raised
1 parent a11d402 commit e8eb1e0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

openrouteservice/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,14 @@ def req(self):
225225
@staticmethod
226226
def _get_body(response):
227227
"""Returns the body of a response object, raises status code exceptions if necessary."""
228-
body = response.json()
228+
try:
229+
body = response.json()
230+
except json.JSONDecodeError:
231+
raise exceptions.HTTPError(response.status_code)
232+
229233
# error = body.get('error')
230234
status_code = response.status_code
231-
235+
232236
if status_code == 429:
233237
raise exceptions._OverQueryLimit(
234238
status_code,

0 commit comments

Comments
 (0)