diff options
author | Lorenz Diener <[email protected]> | 2019-06-05 11:52:43 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2019-06-05 11:52:43 +0200 |
commit | 1a120f03939d36bc14bda0931819db0ab45908af (patch) | |
tree | d7507fecfa6bb037a25e7cc73d0c3911f48200bc | |
parent | 6dd18764e39cff0a42aa0f21f88dc1cf4a8e8c63 (diff) | |
parent | e6ed107fdf2c96bf1c698b212e3e0d4a1102e4d0 (diff) | |
download | mastodon.py-1a120f03939d36bc14bda0931819db0ab45908af.tar.gz |
Merge pull request #174 from lefherz/master
extended MastodonServerError for all 5xx error codes
-rw-r--r-- | mastodon/Mastodon.py | 29 | ||||
-rw-r--r-- | mastodon/__init__.py | 4 |
2 files changed, 29 insertions, 4 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 65ce518..ef71078 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -2750,7 +2750,16 @@ class Mastodon: | |||
2750 | # on any 404 | 2750 | # on any 404 |
2751 | elif response_object.status_code == 401: | 2751 | elif response_object.status_code == 401: |
2752 | ex_type = MastodonUnauthorizedError | 2752 | ex_type = MastodonUnauthorizedError |
2753 | elif response_object.status_code == 500: | ||
2754 | ex_type = MastodonInternalServerError | ||
2753 | elif response_object.status_code == 502: | 2755 | elif response_object.status_code == 502: |
2756 | ex_type = MastodonBadGatewayError | ||
2757 | elif response_object.status_code == 503: | ||
2758 | ex_type = MastodonServiceUnavailableError | ||
2759 | elif response_object.status_code == 504: | ||
2760 | ex_type = MastodonGatewayTimeoutError | ||
2761 | elif response_object.status_code >= 500 and \ | ||
2762 | response_object.status_code <= 511: | ||
2754 | ex_type = MastodonServerError | 2763 | ex_type = MastodonServerError |
2755 | else: | 2764 | else: |
2756 | ex_type = MastodonAPIError | 2765 | ex_type = MastodonAPIError |
@@ -3067,8 +3076,24 @@ class MastodonAPIError(MastodonError): | |||
3067 | """Raised when the mastodon API generates a response that cannot be handled""" | 3076 | """Raised when the mastodon API generates a response that cannot be handled""" |
3068 | pass | 3077 | pass |
3069 | 3078 | ||
3070 | class MastodonServerError(MastodonError): | 3079 | class MastodonServerError(MastodonAPIError): |
3071 | """Raised if the Server is malconfigured, e.g. returns a 502 error code""" | 3080 | """Raised if the Server is malconfigured and returns a 5xx error code""" |
3081 | pass | ||
3082 | |||
3083 | class MastodonInternalServerError(MastodonServerError): | ||
3084 | """Raised if the Server returns a 500 error""" | ||
3085 | pass | ||
3086 | |||
3087 | class MastodonBadGatewayError(MastodonServerError): | ||
3088 | """Raised if the Server returns a 502 error""" | ||
3089 | pass | ||
3090 | |||
3091 | class MastodonServiceUnavailableError(MastodonServerError): | ||
3092 | """Raised if the Server returns a 503 error""" | ||
3093 | pass | ||
3094 | |||
3095 | class MastodonGatewayTimeoutError(MastodonServerError): | ||
3096 | """Raised if the Server returns a 504 error""" | ||
3072 | pass | 3097 | pass |
3073 | 3098 | ||
3074 | class MastodonNotFoundError(MastodonAPIError): | 3099 | class MastodonNotFoundError(MastodonAPIError): |
diff --git a/mastodon/__init__.py b/mastodon/__init__.py index 1be4aba..047ffb7 100644 --- a/mastodon/__init__.py +++ b/mastodon/__init__.py | |||
@@ -1,5 +1,5 @@ | |||
1 | from mastodon.Mastodon import Mastodon, AttribAccessDict, MastodonError, MastodonVersionError, MastodonIllegalArgumentError, MastodonIOError, MastodonFileNotFoundError, MastodonNetworkError, MastodonAPIError, MastodonNotFoundError, MastodonUnauthorizedError, MastodonRatelimitError, MastodonMalformedEventError, MastodonServerError | 1 | from mastodon.Mastodon import Mastodon, AttribAccessDict, MastodonError, MastodonVersionError, MastodonIllegalArgumentError, MastodonIOError, MastodonFileNotFoundError, MastodonNetworkError, MastodonAPIError, MastodonNotFoundError, MastodonUnauthorizedError, MastodonRatelimitError, MastodonMalformedEventError, MastodonServerError, MastodonInternalServerError, MastodonBadGatewayError, MastodonServiceUnavailableError, MastodonGatewayTimeoutError |
2 | from mastodon.streaming import StreamListener, CallbackStreamListener | 2 | from mastodon.streaming import StreamListener, CallbackStreamListener |
3 | 3 | ||
4 | __all__ = ['Mastodon', 'AttribAccessDict', 'StreamListener', 'CallbackStreamListener', 'MastodonError', 'MastodonVersionError', 'MastodonIllegalArgumentError', 'MastodonIOError', 'MastodonFileNotFoundError', 'MastodonNetworkError', 'MastodonAPIError', 'MastodonNotFoundError', 'MastodonUnauthorizedError', 'MastodonRatelimitError', 'MastodonMalformedEventError', | 4 | __all__ = ['Mastodon', 'AttribAccessDict', 'StreamListener', 'CallbackStreamListener', 'MastodonError', 'MastodonVersionError', 'MastodonIllegalArgumentError', 'MastodonIOError', 'MastodonFileNotFoundError', 'MastodonNetworkError', 'MastodonAPIError', 'MastodonNotFoundError', 'MastodonUnauthorizedError', 'MastodonRatelimitError', 'MastodonMalformedEventError', |
5 | 'MastodonServerError'] | 5 | 'MastodonServerError', 'MastodonInternalServerError', 'MastodonBadGatewayError', 'MastodonServiceUnavailableError', 'MastodonGatewayTimeoutError'] |