2 # Copyright 2009-2010 Joshua Roesslein
3 # See LICENSE for details.
5 from __future__ import print_function
9 class TweepError(Exception):
10 """Tweepy exception"""
12 def __init__(self, reason, response=None):
13 self.reason = six.text_type(reason)
14 self.response = response
15 Exception.__init__(self, reason)
20 def is_rate_limit_error_message(message):
21 """Check if the supplied error message belongs to a rate limit error."""
22 return isinstance(message, list) \
23 and len(message) > 0 \
24 and 'code' in message[0] \
25 and message[0]['code'] == 88
27 class RateLimitError(TweepError):
28 """Exception for Tweepy hitting the rate limit."""
29 # RateLimitError has the exact same properties and inner workings
30 # as TweepError for backwards compatibility reasons.