working auth + users systems
This commit is contained in:
27
backend/core/exceptions.py
Normal file
27
backend/core/exceptions.py
Normal file
@@ -0,0 +1,27 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user