12 lines
383 B
Python
12 lines
383 B
Python
from fastapi import Request
|
|
from fastapi.responses import ORJSONResponse
|
|
from starlette.exceptions import HTTPException
|
|
|
|
|
|
async def http_exception_handler(_request: Request, exc: HTTPException) -> ORJSONResponse:
|
|
return ORJSONResponse(
|
|
status_code=exc.status_code,
|
|
content={'detail': exc.detail},
|
|
headers=dict(exc.headers) if exc.headers else None,
|
|
)
|