from ninja.errors import HttpError


class EPAPIError(HttpError):
    status_code: int = 500

    def __init__(self, message: str) -> None:
        super().__init__(status_code=self.status_code, message=message)

    @classmethod
    def from_exception(cls, exc: Exception):
        return cls(message=str(exc))


class EPAPIUnauthorizedError(EPAPIError):
    status_code = 401


class EPAPIPermissionDeniedError(EPAPIError):
    status_code = 403


class EPAPINotFoundError(EPAPIError):
    status_code = 404


class EPAPIValidationError(EPAPIError):
    status_code = 422
