first commit
This commit is contained in:
21
app/core/exceptions.py
Normal file
21
app/core/exceptions.py
Normal file
@@ -0,0 +1,21 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user