+from exceptions import Exception
+
+from twitter.twitter_globals import POST_ACTIONS
+from twitter.auth import UserPassAuth, NoAuth
+
+def _py26OrGreater():
+ import sys
+ return sys.hexversion > 0x20600f0
+
+if _py26OrGreater():
+ import json
+else:
+ import simplejson as json
+
+class TwitterError(Exception):
+ """
+ Base Exception thrown by the Twitter object when there is a
+ general error interacting with the API.
+ """
+ pass
+
+class TwitterHTTPError(TwitterError):
+ """
+ Exception thrown by the Twitter object when there is an
+ HTTP error interacting with twitter.com.
+ """
+ def __init__(self, e, uri, format, encoded_args):
+ self.e = e
+ self.uri = uri
+ self.format = format
+ self.encoded_args = encoded_args
+
+ def __str__(self):
+ return "Twitter sent status %i for URL: %s.%s using parameters: (%s)\ndetails: %s" %(
+ self.e.code, self.uri, self.format, self.encoded_args, self.e.fp.read())