better handling of non-standard error responses, such as from pleroma

This commit is contained in:
codl 2019-03-11 14:51:11 +01:00
pare 3f83ee0a4c
commit 0666bdabf1
No se encontró ninguna clave conocida en la base de datos para esta firma
ID de clave GPG: 6CD7C8891ED1233A

Veure arxiu

@ -2214,9 +2214,12 @@ class Mastodon:
if not response_object.ok:
try:
response = response_object.json(object_hook=self.__json_hooks)
if not isinstance(response, dict) or 'error' not in response:
if isinstance(response, dict) and 'error' in response:
error_msg = response['error']
elif isinstance(response, str):
error_msg = response
else:
error_msg = None
error_msg = response['error']
except ValueError:
error_msg = None