From: Josh Roesslein Date: Tue, 8 Sep 2009 15:06:31 +0000 (-0500) Subject: Better handle twitter error responses w/o json error info. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=52e3b3e282214afd3638f1883e6036f2d5c0221b;p=tweepy.git Better handle twitter error responses w/o json error info. --- diff --git a/tweepy/binder.py b/tweepy/binder.py index cc4d526..7b4f8a5 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -93,10 +93,12 @@ def bind_api(path, parser, allowed_param=None, method='GET', require_auth=False, resp = conn.getresponse() # If an error was returned, throw an exception - if resp.status == 500: - raise TweepError('Twitter server error!') - if resp.status != 200: - raise TweepError(parse_error(resp.read())) + if resp.status != 200: + try: + error_msg = parse_error(resp.read()) + except Exception: + error_msg = "Unkown twitter error response received: status=%s" % resp.status + raise TweepError(error_msg) # Pass returned body into parser and return parser output out = parser(resp.read(), api)