diff options
author | Lorenz Diener <[email protected]> | 2019-04-27 17:17:08 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2019-04-27 17:17:08 +0200 |
commit | 450ebd983f0d71fed9bf6d874028d8adcc20992e (patch) | |
tree | 1c1a0b4ffea4227eb8b8964a10c36a9144441ad6 /mastodon | |
parent | 8b8626978752baf14347498640b2319db832145e (diff) | |
parent | e594bad9bb5c459862e7837b42b471d9e5937b6c (diff) | |
download | mastodon.py-450ebd983f0d71fed9bf6d874028d8adcc20992e.tar.gz |
Merge pull request #162 from codl/160
better handling of non-standard error responses, such as from pleroma
Diffstat (limited to 'mastodon')
-rw-r--r-- | mastodon/Mastodon.py | 7 |
1 files 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: | |||
2214 | if not response_object.ok: | 2214 | if not response_object.ok: |
2215 | try: | 2215 | try: |
2216 | response = response_object.json(object_hook=self.__json_hooks) | 2216 | response = response_object.json(object_hook=self.__json_hooks) |
2217 | if not isinstance(response, dict) or 'error' not in response: | 2217 | if isinstance(response, dict) and 'error' in response: |
2218 | error_msg = response['error'] | ||
2219 | elif isinstance(response, str): | ||
2220 | error_msg = response | ||
2221 | else: | ||
2218 | error_msg = None | 2222 | error_msg = None |
2219 | error_msg = response['error'] | ||
2220 | except ValueError: | 2223 | except ValueError: |
2221 | error_msg = None | 2224 | error_msg = None |
2222 | 2225 | ||