aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py29
-rw-r--r--mastodon/__init__.py4
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
3070class MastodonServerError(MastodonError): 3079class 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
3083class MastodonInternalServerError(MastodonServerError):
3084 """Raised if the Server returns a 500 error"""
3085 pass
3086
3087class MastodonBadGatewayError(MastodonServerError):
3088 """Raised if the Server returns a 502 error"""
3089 pass
3090
3091class MastodonServiceUnavailableError(MastodonServerError):
3092 """Raised if the Server returns a 503 error"""
3093 pass
3094
3095class MastodonGatewayTimeoutError(MastodonServerError):
3096 """Raised if the Server returns a 504 error"""
3072 pass 3097 pass
3073 3098
3074class MastodonNotFoundError(MastodonAPIError): 3099class 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 @@
1from mastodon.Mastodon import Mastodon, AttribAccessDict, MastodonError, MastodonVersionError, MastodonIllegalArgumentError, MastodonIOError, MastodonFileNotFoundError, MastodonNetworkError, MastodonAPIError, MastodonNotFoundError, MastodonUnauthorizedError, MastodonRatelimitError, MastodonMalformedEventError, MastodonServerError 1from mastodon.Mastodon import Mastodon, AttribAccessDict, MastodonError, MastodonVersionError, MastodonIllegalArgumentError, MastodonIOError, MastodonFileNotFoundError, MastodonNetworkError, MastodonAPIError, MastodonNotFoundError, MastodonUnauthorizedError, MastodonRatelimitError, MastodonMalformedEventError, MastodonServerError, MastodonInternalServerError, MastodonBadGatewayError, MastodonServiceUnavailableError, MastodonGatewayTimeoutError
2from mastodon.streaming import StreamListener, CallbackStreamListener 2from 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']
Powered by cgit v1.2.3 (git 2.41.0)