Merge pull request #174 from lefherz/master
extended MastodonServerError for all 5xx error codes
This commit is contained in:
commit
1a120f0393
S'han modificat 2 arxius amb 29 adicions i 4 eliminacions
|
@ -2750,7 +2750,16 @@ 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:
|
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 \
|
||||||
|
response_object.status_code <= 511:
|
||||||
ex_type = MastodonServerError
|
ex_type = MastodonServerError
|
||||||
else:
|
else:
|
||||||
ex_type = MastodonAPIError
|
ex_type = MastodonAPIError
|
||||||
|
@ -3067,8 +3076,24 @@ 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, e.g. returns a 502 error code"""
|
"""Raised if the Server is malconfigured and returns a 5xx error code"""
|
||||||
|
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
|
pass
|
||||||
|
|
||||||
class MastodonNotFoundError(MastodonAPIError):
|
class MastodonNotFoundError(MastodonAPIError):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from mastodon.Mastodon import Mastodon, AttribAccessDict, MastodonError, MastodonVersionError, MastodonIllegalArgumentError, MastodonIOError, MastodonFileNotFoundError, MastodonNetworkError, MastodonAPIError, MastodonNotFoundError, MastodonUnauthorizedError, MastodonRatelimitError, MastodonMalformedEventError, MastodonServerError
|
from mastodon.Mastodon import Mastodon, AttribAccessDict, MastodonError, MastodonVersionError, MastodonIllegalArgumentError, MastodonIOError, MastodonFileNotFoundError, MastodonNetworkError, MastodonAPIError, MastodonNotFoundError, MastodonUnauthorizedError, MastodonRatelimitError, MastodonMalformedEventError, MastodonServerError, MastodonInternalServerError, MastodonBadGatewayError, MastodonServiceUnavailableError, MastodonGatewayTimeoutError
|
||||||
from mastodon.streaming import StreamListener, CallbackStreamListener
|
from mastodon.streaming import StreamListener, CallbackStreamListener
|
||||||
|
|
||||||
__all__ = ['Mastodon', 'AttribAccessDict', 'StreamListener', 'CallbackStreamListener', 'MastodonError', 'MastodonVersionError', 'MastodonIllegalArgumentError', 'MastodonIOError', 'MastodonFileNotFoundError', 'MastodonNetworkError', 'MastodonAPIError', 'MastodonNotFoundError', 'MastodonUnauthorizedError', 'MastodonRatelimitError', 'MastodonMalformedEventError',
|
__all__ = ['Mastodon', 'AttribAccessDict', 'StreamListener', 'CallbackStreamListener', 'MastodonError', 'MastodonVersionError', 'MastodonIllegalArgumentError', 'MastodonIOError', 'MastodonFileNotFoundError', 'MastodonNetworkError', 'MastodonAPIError', 'MastodonNotFoundError', 'MastodonUnauthorizedError', 'MastodonRatelimitError', 'MastodonMalformedEventError',
|
||||||
'MastodonServerError']
|
'MastodonServerError', 'MastodonInternalServerError', 'MastodonBadGatewayError', 'MastodonServiceUnavailableError', 'MastodonGatewayTimeoutError']
|
||||||
|
|
Loading…
Referencia en una nova incidència