Spaces:
Sleeping
Sleeping
| 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, | |
| ) | |