Spaces:
Sleeping
Sleeping
File size: 1,351 Bytes
0326035 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
from fastapi import HTTPException, status
class PrepMindException(HTTPException):
"""Base exception for PrepMind"""
pass
class AuthenticationException(PrepMindException):
def __init__(self, detail: str = "Could not validate credentials"):
super().__init__(
status_code=status.HTTP_401_UNAUTHORIZED,
detail=detail,
headers={"WWW-Authenticate": "Bearer"},
)
class NotFoundException(PrepMindException):
def __init__(self, detail: str = "Resource not found"):
super().__init__(
status_code=status.HTTP_404_NOT_FOUND,
detail=detail,
)
class BadRequestException(PrepMindException):
def __init__(self, detail: str = "Bad request"):
super().__init__(
status_code=status.HTTP_400_BAD_REQUEST,
detail=detail,
)
class ForbiddenException(PrepMindException):
def __init__(self, detail: str = "Access forbidden"):
super().__init__(
status_code=status.HTTP_403_FORBIDDEN,
detail=detail,
)
class ConflictException(PrepMindException):
def __init__(self, detail: str = "Resource already exists"):
super().__init__(
status_code=status.HTTP_409_CONFLICT,
detail=detail,
)
|