fooder-api/fooder/exc.py

35 lines
691 B
Python

from typing import ClassVar
class ApiException(Exception):
HTTP_CODE: ClassVar[int]
MESSAGE: ClassVar[str]
def __init__(self, message: str | None = None) -> None:
self.message = message or self.MESSAGE
super().__init__(self.message)
class NotFound(ApiException):
HTTP_CODE = 404
MESSAGE = "Not found"
class Unauthorized(ApiException):
HTTP_CODE = 401
MESSAGE = "Unauthorized"
class InvalidValue(ApiException):
HTTP_CODE = 400
MESSAGE = "Invalid value"
class Conflict(ApiException):
HTTP_CODE = 409
MESSAGE = "Conflict"
class CaptchaFailed(ApiException):
HTTP_CODE = 403
MESSAGE = "Captcha verification failed"