X-Git-Url: https://projects.mako.cc/source/twitter-api-cdsw/blobdiff_plain/b5d973d7a0a14eca21b2981ffacf4fb9ea77ba41..4b0f484cf92d3dd4a04eff17a3c52e2dd1dde9b1:/tweepy/error.py?ds=inline diff --git a/tweepy/error.py b/tweepy/error.py index 1c47a5a..7827029 100644 --- a/tweepy/error.py +++ b/tweepy/error.py @@ -6,7 +6,6 @@ from __future__ import print_function import six - class TweepError(Exception): """Tweepy exception""" @@ -17,3 +16,16 @@ class TweepError(Exception): def __str__(self): return self.reason + +def is_rate_limit_error_message(message): + """Check if the supplied error message belongs to a rate limit error.""" + return isinstance(message, list) \ + and len(message) > 0 \ + and 'code' in message[0] \ + and message[0]['code'] == 88 + +class RateLimitError(TweepError): + """Exception for Tweepy hitting the rate limit.""" + # RateLimitError has the exact same properties and inner workings + # as TweepError for backwards compatibility reasons. + pass