simplify exceptions
@@ -45,20 +45,19 @@ class HTTPError(RequestException):
class InternalServerError(HTTPError):
- def __init__(self, msg, status_code):
- super().__init__(msg, status_code)
- logger.debug(f"Internal server error: error='{msg}'")
+ @classmethod
+ def from_request_exception(cls, request_exception):
+ exception = super().from_request_exception(request_exception)
+ logger.debug(f"Invalid request: error='{exception.msg}'")
+ return exception
class InvalidRequest(HTTPError):
- def __init__(self, msg, status_code):
- super().__init__(msg, status_code)
- logger.debug(f"Invalid request: error='{msg}'")
-
@classmethod
def from_request_exception(cls, request_exception):
error = request_exception.response.json()
msg = error.get('message', None)
+ logger.debug(f"Invalid request: error='{msg}'")
return super().from_request_exception(request_exception, msg)
