Fix wrong api key error handling
This commit is contained in:
@ -1 +1 @@
|
||||
from .handler import setup_exception_handler
|
||||
from .handler import setup_exception_handler, exception_handler
|
||||
|
||||
@ -13,8 +13,12 @@ def setup_exception_handler(app: FastAPI):
|
||||
Setup exception handler for FastAPI.
|
||||
'''
|
||||
@app.exception_handler(HTTPException)
|
||||
async def http_exception_handler(request: Request, exc: HTTPException): # type: ignore
|
||||
return JSONResponse(
|
||||
status_code=exc.status_code,
|
||||
content=JSONErrorResponse(status=exc.status_code, detail=exc.detail).model_dump(),
|
||||
)
|
||||
async def http_exception_handler_wrapper(request: Request, exc: HTTPException): # type: ignore
|
||||
return exception_handler(exc)
|
||||
|
||||
|
||||
def exception_handler(exc: HTTPException): # type: ignore
|
||||
return JSONResponse(
|
||||
status_code=exc.status_code,
|
||||
content=JSONErrorResponse(status=exc.status_code, detail=exc.detail).model_dump(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user