mirror of
https://github.com/fastapi-admin/fastapi-admin.git
synced 2025-08-14 18:58:13 +08:00
new project
This commit is contained in:
@ -1,7 +1,33 @@
|
||||
from fastapi.exceptions import HTTPException
|
||||
from starlette.requests import Request
|
||||
from starlette.responses import JSONResponse
|
||||
from fastapi import HTTPException
|
||||
from starlette.status import HTTP_500_INTERNAL_SERVER_ERROR
|
||||
|
||||
|
||||
async def exception_handler(request: Request, exc: HTTPException):
|
||||
return JSONResponse(status_code=exc.status_code, content={"msg": exc.detail},)
|
||||
class ServerHTTPException(HTTPException):
|
||||
def __init__(self, error: str = None):
|
||||
super(ServerHTTPException, self).__init__(
|
||||
status_code=HTTP_500_INTERNAL_SERVER_ERROR, detail=error
|
||||
)
|
||||
|
||||
|
||||
class InvalidResource(ServerHTTPException):
|
||||
"""
|
||||
raise when has invalid resource
|
||||
"""
|
||||
|
||||
|
||||
class NoSuchFieldFound(ServerHTTPException):
|
||||
"""
|
||||
raise when no such field for the given
|
||||
"""
|
||||
|
||||
|
||||
class FileMaxSizeLimit(ServerHTTPException):
|
||||
"""
|
||||
raise when the upload file exceeds the max size
|
||||
"""
|
||||
|
||||
|
||||
class FileExtNotAllowed(ServerHTTPException):
|
||||
"""
|
||||
raise when the upload file ext not allowed
|
||||
"""
|
||||
|
Reference in New Issue
Block a user