Home / Function/ http_exception_handler() — fastapi Function Reference

http_exception_handler() — fastapi Function Reference

Architecture documentation for the http_exception_handler() function in exception_handlers.py from the fastapi codebase.

Function python FastAPI Routing calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  b7aaa327_256c_826b_6da4_7f2714292af0["http_exception_handler()"]
  2d259205_f589_7dee_455a_60e1c67ed35e["exception_handlers.py"]
  b7aaa327_256c_826b_6da4_7f2714292af0 -->|defined in| 2d259205_f589_7dee_455a_60e1c67ed35e
  13e50071_8b14_4f66_6cc3_c17c1e0899ac["custom_http_exception_handler()"]
  13e50071_8b14_4f66_6cc3_c17c1e0899ac -->|calls| b7aaa327_256c_826b_6da4_7f2714292af0
  dba5a7c0_1fab_8f88_2c80_2b79c3b3dc47["is_body_allowed_for_status_code()"]
  b7aaa327_256c_826b_6da4_7f2714292af0 -->|calls| dba5a7c0_1fab_8f88_2c80_2b79c3b3dc47
  style b7aaa327_256c_826b_6da4_7f2714292af0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fastapi/exception_handlers.py lines 11–17

async def http_exception_handler(request: Request, exc: HTTPException) -> Response:
    headers = getattr(exc, "headers", None)
    if not is_body_allowed_for_status_code(exc.status_code):
        return Response(status_code=exc.status_code, headers=headers)
    return JSONResponse(
        {"detail": exc.detail}, status_code=exc.status_code, headers=headers
    )

Domain

Subdomains

Frequently Asked Questions

What does http_exception_handler() do?
http_exception_handler() is a function in the fastapi codebase, defined in fastapi/exception_handlers.py.
Where is http_exception_handler() defined?
http_exception_handler() is defined in fastapi/exception_handlers.py at line 11.
What does http_exception_handler() call?
http_exception_handler() calls 1 function(s): is_body_allowed_for_status_code.
What calls http_exception_handler()?
http_exception_handler() is called by 1 function(s): custom_http_exception_handler.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free