Files
superDreamFront/app/core/exceptions.py
2026-04-15 21:35:26 +08:00

21 lines
683 B
Python

from fastapi import HTTPException
class NotFoundError(HTTPException):
def __init__(self, detail: str = "Resource not found"):
super().__init__(status_code=404, detail=detail)
class BadRequestError(HTTPException):
def __init__(self, detail: str = "Bad request"):
super().__init__(status_code=400, detail=detail)
class UnauthorizedError(HTTPException):
def __init__(self, detail: str = "Not authenticated"):
super().__init__(status_code=401, detail=detail, headers={"WWW-Authenticate": "Bearer"})
class ForbiddenError(HTTPException):
def __init__(self, detail: str = "Forbidden"):
super().__init__(status_code=403, detail=detail)