Merge pull request #158 from lefherz/master

New exception class if server is malconfigured, e.g. 502
This commit is contained in:
Lorenz Diener 2019-04-27 17:23:46 +02:00 cometido por GitHub
commit 351d302531
No se encontró ninguna clave conocida en la base de datos para esta firma
ID de clave GPG: 4AEE18F83AFDEB23

Veure arxiu

@ -2245,6 +2245,8 @@ 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 == 502:
ex_type = MastodonServerError
else: else:
ex_type = MastodonAPIError ex_type = MastodonAPIError
@ -2539,6 +2541,10 @@ 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):
"""Raised if the Server is malconfigured, e.g. returns a 502 error code"""
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