Log error message parse failures
If errors from the Twitter API are not JSON they can cause strange
errors. Instead we should catch these and log what was received from
Twitter instead of JSON.
Refs
@@ -175,6 +175,7 @@ class cli_api_error():
try:
return self.f(*args, **kwargs)
except HTTPError as e:
+ try:
result = e.response.json()
if 'errors' in result:
for error in result['errors']:
@@ -183,6 +184,8 @@ class cli_api_error():
msg = result['title']
else:
msg = 'Unknown error'
+ except JSONDecodeError:
+ msg = 'Unable to parse error as JSON, received: ' + e.response.text
except InvalidAuthType as e:
msg = "This command requires application authentication, try passing --app-auth"
except ValueError as e:
