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

add detailed error message #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

pedroheyerdahl
Copy link
Contributor

Include verbose error logging.

@@ -83,9 +83,10 @@ def validate_response(self, response: requests.Response) -> None:
time.sleep(retry_after)
raise RetriableAPIError(msg)
elif 400 <= response.status_code < 500:
error_text = json.loads(response.text)
Copy link
Contributor

Choose a reason for hiding this comment

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

You can grab the response as a dict with response.json() so you don't have to parse the text yourself.

Another note here that because this catches all http codes between the range 400 and 500 they all might not have the error field which might cause the below part of error_text['error'] to fail with a KeyError. This can be worked around by using the get() method, which can handle default values in case of missing keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants