better inheritance cascade for HTTP error codes, implemented more errors
This commit is contained in:
pare
a9087f0262
commit
21e12cfb58
S'han modificat 1 arxius amb 25 adicions i 1 eliminacions
|
@ -2750,6 +2750,14 @@ class Mastodon:
|
||||||
# on any 404
|
# on any 404
|
||||||
elif response_object.status_code == 401:
|
elif response_object.status_code == 401:
|
||||||
ex_type = MastodonUnauthorizedError
|
ex_type = MastodonUnauthorizedError
|
||||||
|
elif response_object.status_code == 500:
|
||||||
|
ex_type = MastodonInternalServerError
|
||||||
|
elif response_object.status_code == 502:
|
||||||
|
ex_type = MastodonBadGatewayError
|
||||||
|
elif response_object.status_code == 503:
|
||||||
|
ex_type = MastodonServiceUnavailableError
|
||||||
|
elif response_object.status_code == 504:
|
||||||
|
ex_type = MastodonGatewayTimeoutError
|
||||||
elif response_object.status_code >= 500 and \
|
elif response_object.status_code >= 500 and \
|
||||||
response_object.status_code <= 511:
|
response_object.status_code <= 511:
|
||||||
ex_type = MastodonServerError
|
ex_type = MastodonServerError
|
||||||
|
@ -3068,10 +3076,26 @@ class MastodonAPIError(MastodonError):
|
||||||
"""Raised when the mastodon API generates a response that cannot be handled"""
|
"""Raised when the mastodon API generates a response that cannot be handled"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class MastodonServerError(MastodonError):
|
class MastodonServerError(MastodonAPIError):
|
||||||
"""Raised if the Server is malconfigured and returns a 5xx error code"""
|
"""Raised if the Server is malconfigured and returns a 5xx error code"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class MastodonInternalServerError(MastodonServerError)
|
||||||
|
"""Raised if the Server returns a 500 error"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
class MastodonBadGatewayError(MastodonServerError)
|
||||||
|
"""Raised if the Server returns a 502 error"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
class MastodonServiceUnavailableError(MastodonServerError)
|
||||||
|
"""Raised if the Server returns a 503 error"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
class MastodonGatewayTimeoutError(MastodonServerError)
|
||||||
|
"""Raised if the Server returns a 504 error"""
|
||||||
|
pass
|
||||||
|
|
||||||
class MastodonNotFoundError(MastodonAPIError):
|
class MastodonNotFoundError(MastodonAPIError):
|
||||||
"""Raised when the mastodon API returns a 404 Not Found error"""
|
"""Raised when the mastodon API returns a 404 Not Found error"""
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Referencia en una nova incidència