MCPcopy
hub / github.com/fastapi/fastapi / http_exception_handler

Function http_exception_handler

fastapi/exception_handlers.py:11–17  ·  view source on GitHub ↗
(request: Request, exc: HTTPException)

Source from the content-addressed store, hash-verified

9
10
11async def http_exception_handler(request: Request, exc: HTTPException) -> Response:
12 headers = getattr(exc, "headers", None)
13 if not is_body_allowed_for_status_code(exc.status_code):
14 return Response(status_code=exc.status_code, headers=headers)
15 return JSONResponse(
16 {"detail": exc.detail}, status_code=exc.status_code, headers=headers
17 )
18
19
20async def request_validation_exception_handler(

Callers 1

Calls 2

ResponseClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…