twython icon indicating copy to clipboard operation
twython copied to clipboard

TwythonError hides too many details from error message

Open anentropic opened this issue 7 years ago • 1 comments

errors are raised something like:

raise TwythonError(
    error_message,  # text of first error if there are multiple
    error_code=response.status_code,
)

In Twitter API docs the errors are assigned an error code

For example the rate limit for posting status updates will return http 403 with error code 88, but the TwythonError only gives us 403 (plus the message "Rate limit exceeded")

So we can match on the text of the error but we wonder if Twitter may localise the text or amend the description at some point.

It would be nice to have access to the error code in error_code, with the http response status code as a separate attribute. In fact it would be useful to have the whole error body to work with.

anentropic avatar Feb 06 '18 18:02 anentropic

@anentropic that sounds wonderful. I'd be open to a PR that changes error_code to the Twitter error_code and a new status_code attribute on TwythonError

michaelhelmick avatar Feb 07 '18 15:02 michaelhelmick