/usr/lib/python3/dist-packages/twython/exceptions.py is in python3-twython 3.1.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | # -*- coding: utf-8 -*-
"""
twython.exceptions
~~~~~~~~~~~~~~~~~~
This module contains Twython specific Exception classes.
"""
from .endpoints import TWITTER_HTTP_STATUS_CODE
class TwythonError(Exception):
"""Generic error class, catch-all for most Twython issues.
Special cases are handled by TwythonAuthError & TwythonRateLimitError.
from twython import TwythonError, TwythonRateLimitError, TwythonAuthError
"""
def __init__(self, msg, error_code=None, retry_after=None):
self.error_code = error_code
if error_code is not None and error_code in TWITTER_HTTP_STATUS_CODE:
msg = 'Twitter API returned a %s (%s), %s' % \
(error_code,
TWITTER_HTTP_STATUS_CODE[error_code][0],
msg)
super(TwythonError, self).__init__(msg)
@property
def msg(self): # pragma: no cover
return self.args[0]
class TwythonAuthError(TwythonError):
"""Raised when you try to access a protected resource and it fails due to
some issue with your authentication.
"""
pass
class TwythonRateLimitError(TwythonError): # pragma: no cover
"""Raised when you've hit a rate limit.
The amount of seconds to retry your request in will be appended
to the message.
"""
def __init__(self, msg, error_code, retry_after=None):
if isinstance(retry_after, int):
msg = '%s (Retry after %d seconds)' % (msg, retry_after)
TwythonError.__init__(self, msg, error_code=error_code)
class TwythonStreamError(TwythonError):
"""Raised when an invalid response from the Stream API is received"""
pass
|