Generic error class, catch-all for most Twython issues. Special cases are handled by TwythonAuthError & TwythonRateLimitError. from twython import TwythonError, TwythonRateLimitError, TwythonAuthError
| 11 | |
| 12 | |
| 13 | class TwythonError(Exception): |
| 14 | """Generic error class, catch-all for most Twython issues. |
| 15 | Special cases are handled by TwythonAuthError & TwythonRateLimitError. |
| 16 | |
| 17 | from twython import TwythonError, TwythonRateLimitError, TwythonAuthError |
| 18 | |
| 19 | """ |
| 20 | def __init__(self, msg, error_code=None, retry_after=None): |
| 21 | self.error_code = error_code |
| 22 | |
| 23 | if error_code is not None and error_code in TWITTER_HTTP_STATUS_CODE: |
| 24 | msg = 'Twitter API returned a %s (%s), %s' % \ |
| 25 | (error_code, |
| 26 | TWITTER_HTTP_STATUS_CODE[error_code][0], |
| 27 | msg) |
| 28 | |
| 29 | super(TwythonError, self).__init__(msg) |
| 30 | |
| 31 | @property |
| 32 | def msg(self): # pragma: no cover |
| 33 | return self.args[0] |
| 34 | |
| 35 | |
| 36 | class TwythonAuthError(TwythonError): |
no outgoing calls
no test coverage detected