Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only decode and return browser content in the successful case #162

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions openqa_review/browser.py
Expand Up @@ -144,8 +144,13 @@ 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")
return content
try:
content = r.json() if as_json else r.content.decode("utf8")
return content
except json.decoder.JSONDecodeError as e:
msg = "Failed to decode {}: {}".format(r.content, str(e))
log.warn(msg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before we escalate the message with "warning" level I would like to understand what can be the reason for such cases encountered. Should we ignore such issues? Then make it less than "warn". Should we handle such issues? Then "warn" is not high enough.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the reason. All i know is that we get invalid JSON, which I'm surfacing here, that the traceback doesn't contain. And I'd consider that an error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if the URL could be included in the error message.

raise DownloadError(msg)

def json_rpc_get(self, url, method, params, cache=True):
"""Execute JSON RPC GET request."""
Expand Down