Skip to content

Commit

Permalink
Catch JSON decoding errors in browser.get
Browse files Browse the repository at this point in the history
  • Loading branch information
kalikiana committed Oct 11, 2021
1 parent 915db1b commit c494844
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion openqa_review/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ def _get(self, url, as_json=False): # pragma: no cover
log.warn(msg)
raise DownloadError(msg)

content = r.json() if as_json else r.content.decode("utf8")
try:
content = r.json() if as_json else r.content.decode("utf8")
except JSONDecodeError as e:
msg = "Unable to decode JSON for {}: {}".format(url, r.content.decode("utf8"))
log.warn(msg)
raise DownloadError(msg)
return content

def json_rpc_get(self, url, method, params, cache=True):
Expand Down

0 comments on commit c494844

Please sign in to comment.