From 280973661d5d5b7528b42252537113435732366c Mon Sep 17 00:00:00 2001 From: lefherz Date: Sun, 3 Feb 2019 01:58:40 +0100 Subject: [PATCH] New exception class if server is malconfigured, e.g. 502 --- mastodon/Mastodon.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index fc585ba..27c98af 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -2242,6 +2242,8 @@ class Mastodon: # on any 404 elif response_object.status_code == 401: ex_type = MastodonUnauthorizedError + elif response_object.status_code == 502: + ex_type = MastodonServerError else: ex_type = MastodonAPIError @@ -2528,6 +2530,10 @@ class MastodonAPIError(MastodonError): """Raised when the mastodon API generates a response that cannot be handled""" pass +class MastodonServerError(MastodonError): + """Raised if the Server is malconfigured, e.g. returns a 502 error code""" + pass + class MastodonNotFoundError(MastodonAPIError): """Raised when the mastodon API returns a 404 Not Found error""" pass