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)