Handle content-type header charset value for streaming API
[twitter-api-cdsw] / tweepy / error.py
1 # Tweepy
2 # Copyright 2009-2010 Joshua Roesslein
3 # See LICENSE for details.
4
5 from __future__ import print_function
6
7 import six
8
9 class TweepError(Exception):
10     """Tweepy exception"""
11
12     def __init__(self, reason, response=None):
13         self.reason = six.text_type(reason)
14         self.response = response
15         Exception.__init__(self, reason)
16
17     def __str__(self):
18         return self.reason
19
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
26
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.
31     pass

Benjamin Mako Hill || Want to submit a patch?