gist
gist copied to clipboard
Informative errors
Currently if there is a problem with the request to github, the reported error is cryptic because the code assumes success. Check responses and provide a message to help the user understand what the problem is.
Hi,
Do you just want to check the HTTP status codes using something like http://docs.python-requests.org/en/latest/user/quickstart/#response-status-codes
Adding a Response.raise_for_status()
in GistAPI.send()
is one way I can think of solving this.
Yes, it is going to involve checking the returned status. However, raise_for_status is not really the way to go. The idea should be to isolate the caller from the particular transport mechanism used (in this case HTTP) and give them information that is semantically meaningful. So the status codes need to be checked from within GistAPI and appropriate exceptions raised.
An example of where this is an issue is when the token is invalid and the response is something like,
1450282075.615 ERROR[gist] string indices must be integers