demo / utils /exceptions.py
dngan0365's picture
feat: first commit
51ca819
raw
history blame contribute delete
742 Bytes
from fastapi import HTTPException, status
class UnauthorizedException(HTTPException):
def __init__(self, detail: str = "Unauthorized"):
super().__init__(status_code=status.HTTP_401_UNAUTHORIZED, detail=detail)
class ForbiddenException(HTTPException):
def __init__(self, detail: str = "Forbidden"):
super().__init__(status_code=status.HTTP_403_FORBIDDEN, detail=detail)
class NotFoundException(HTTPException):
def __init__(self, detail: str = "Not found"):
super().__init__(status_code=status.HTTP_404_NOT_FOUND, detail=detail)
class BadRequestException(HTTPException):
def __init__(self, detail: str = "Bad request"):
super().__init__(status_code=status.HTTP_400_BAD_REQUEST, detail=detail)