From 52e3b3e282214afd3638f1883e6036f2d5c0221b Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Tue, 8 Sep 2009 10:06:31 -0500 Subject: [PATCH] Better handle twitter error responses w/o json error info. --- tweepy/binder.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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) -- 2.25.1