aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlefherz <[email protected]>2019-06-02 16:37:37 +0200
committerlefherz <[email protected]>2019-06-02 16:37:37 +0200
commit21e12cfb58cf8c94d562e11823c5af00a0b16a4a (patch)
tree522787fa6732d13ef10941843738fdd11d229dc2 /mastodon/Mastodon.py
parenta9087f026297a9ed0bb5f27c31ce203078d0d6fa (diff)
downloadmastodon.py-21e12cfb58cf8c94d562e11823c5af00a0b16a4a.tar.gz
better inheritance cascade for HTTP error codes, implemented more errors
Diffstat (limited to 'mastodon/Mastodon.py')
-rw-r--r--mastodon/Mastodon.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index bfc2a9b..76c22cf 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -2750,6 +2750,14 @@ 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
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
2753 elif response_object.status_code >= 500 and \ 2761 elif response_object.status_code >= 500 and \
2754 response_object.status_code <= 511: 2762 response_object.status_code <= 511:
2755 ex_type = MastodonServerError 2763 ex_type = MastodonServerError
@@ -3068,10 +3076,26 @@ class MastodonAPIError(MastodonError):
3068 """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"""
3069 pass 3077 pass
3070 3078
3071class MastodonServerError(MastodonError): 3079class MastodonServerError(MastodonAPIError):
3072 """Raised if the Server is malconfigured and returns a 5xx error code""" 3080 """Raised if the Server is malconfigured and returns a 5xx error code"""
3073 pass 3081 pass
3074 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"""
3097 pass
3098
3075class MastodonNotFoundError(MastodonAPIError): 3099class MastodonNotFoundError(MastodonAPIError):
3076 """Raised when the mastodon API returns a 404 Not Found error""" 3100 """Raised when the mastodon API returns a 404 Not Found error"""
3077 pass 3101 pass
Powered by cgit v1.2.3 (git 2.41.0)