better handling of non-standard error responses, such as from pleroma
This commit is contained in:
pare
3f83ee0a4c
commit
0666bdabf1
S'han modificat 1 arxius amb 5 adicions i 2 eliminacions
|
@ -2214,9 +2214,12 @@ class Mastodon:
|
||||||
if not response_object.ok:
|
if not response_object.ok:
|
||||||
try:
|
try:
|
||||||
response = response_object.json(object_hook=self.__json_hooks)
|
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 = None
|
|
||||||
error_msg = response['error']
|
error_msg = response['error']
|
||||||
|
elif isinstance(response, str):
|
||||||
|
error_msg = response
|
||||||
|
else:
|
||||||
|
error_msg = None
|
||||||
except ValueError:
|
except ValueError:
|
||||||
error_msg = None
|
error_msg = None
|
||||||
|
|
||||||
|
|
Loading…
Referencia en una nova incidència