34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
from fastapi import HTTPException
|
|
from starlette.status import (
|
|
HTTP_400_BAD_REQUEST,
|
|
HTTP_401_UNAUTHORIZED,
|
|
HTTP_403_FORBIDDEN,
|
|
HTTP_404_NOT_FOUND,
|
|
HTTP_500_INTERNAL_SERVER_ERROR,
|
|
HTTP_409_CONFLICT,
|
|
)
|
|
|
|
|
|
def bad_request_exception(detail: str = "Bad Request"):
|
|
return HTTPException(status_code=HTTP_400_BAD_REQUEST, detail=detail)
|
|
|
|
|
|
def unauthorized_exception(detail: str = "Unauthorized"):
|
|
return HTTPException(status_code=HTTP_401_UNAUTHORIZED, detail=detail)
|
|
|
|
|
|
def forbidden_exception(detail: str = "Forbidden"):
|
|
return HTTPException(status_code=HTTP_403_FORBIDDEN, detail=detail)
|
|
|
|
|
|
def not_found_exception(detail: str = "Not Found"):
|
|
return HTTPException(status_code=HTTP_404_NOT_FOUND, detail=detail)
|
|
|
|
|
|
def internal_server_error_exception(detail: str = "Internal Server Error"):
|
|
return HTTPException(status_code=HTTP_500_INTERNAL_SERVER_ERROR, detail=detail)
|
|
|
|
|
|
def conflict_exception(detail: str = "Conflict"):
|
|
return HTTPException(status_code=HTTP_409_CONFLICT, detail=detail)
|