-
Notifications
You must be signed in to change notification settings - Fork 3
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
Print error when API provides an error. #20
Conversation
sssekai/abcache/__init__.py
Outdated
if 400 <= resp.status_code < 600: | ||
try: # print the error message provided by the API. | ||
self.response_to_dict(resp) | ||
print(resp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use logger.warn("%s" % resp)
for error reporting facilities since that's how the rest of AbCache did things
sssekai/abcache/__init__.py
Outdated
self.response_to_dict(resp) | ||
print(resp) | ||
except: | ||
print(resp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same goes here.
Also it might be a good idea to handle special cases like 503s since this might have no response body - and in that case, it's usally the server doing maintenance work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
503 should be returning
{
"errorCode": "maintenance",
"errorMessage": "",
"httpStatus": 503
}
This doesn't print the errorMessage, just the entire response JSON
LGTM. Thanks again for the PR! Merging now |
AbCache: Print error when API provides an error. #20
@mos9527 there was an issue in the PR code; the line after the "except:" should be |
@YumYummity Made the change here: 0e4a745 |
AbCache: Actually print bad response's content. #20
Thank you! LGTM |
@mos9527 on second thought, doesn't LGTM 💀 Sorry, the |
AbCache: Actually print bad response's content. Again. #20
Fixed in 8b3eda0 |
Don't worry, coding is hard LOL LGTM now. |
This change just makes the function print the error provided by the API.
Sometimes, this can be useful (eg. 403 can have many reasons, and sometimes the API provides a clear reason).