29 lines
551 B
Python
29 lines
551 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
|
|
|
|
|
|
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"
|