From 0666bdabf1c176e9074509f9cb398b4a83b33d2f Mon Sep 17 00:00:00 2001 From: codl Date: Mon, 11 Mar 2019 14:51:11 +0100 Subject: better handling of non-standard error responses, such as from pleroma --- mastodon/Mastodon.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index fc585ba..37e35b7 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -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 -- cgit v1.2.3