Commit e70a29c7 authored by Joshua's avatar Joshua
Browse files

Re-enable parsing of error messages.

parent 27145f41
......@@ -156,8 +156,7 @@ def bind_api(**config):
self.api.last_response = resp
if resp.status != 200:
#TODO: parse error message
raise Exception
error_msg = self.api.parser.parse_error(self,
except Exception:
error_msg = "Twitter error response: status code = %s" % resp.status
raise TweepError(error_msg)
......@@ -16,6 +16,14 @@ class Parser(object):
raise NotImplementedError
def parse_error(self, payload):
Parse the error message from payload.
If unable to parse the message, throw an exception
and default error message will be used.
raise NotImplementedError
class JSONParser(Parser):
......@@ -36,6 +44,9 @@ class JSONParser(Parser):
return json
def parse_error(self, payload):
return self.json_lib.loads(payload)['error']
class ModelParser(JSONParser):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment