exceptions.py — fastapi Source File
Architecture documentation for exceptions.py, a python file in the fastapi codebase. 5 imports, 36 dependents.
Entity Profile
Dependency Diagram
graph LR 01c652c5_d85c_f45e_848e_412c94ea4172["exceptions.py"] 07d79a2e_d4e9_0bbb_be90_936274444c8c["collections.abc"] 01c652c5_d85c_f45e_848e_412c94ea4172 --> 07d79a2e_d4e9_0bbb_be90_936274444c8c 0dda2280_3359_8460_301c_e98c77e78185["typing"] 01c652c5_d85c_f45e_848e_412c94ea4172 --> 0dda2280_3359_8460_301c_e98c77e78185 5efacb44_5373_ceb9_9579_6e6603820488["annotated_doc"] 01c652c5_d85c_f45e_848e_412c94ea4172 --> 5efacb44_5373_ceb9_9579_6e6603820488 6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"] 01c652c5_d85c_f45e_848e_412c94ea4172 --> 6913fbd4_39df_d14b_44bb_522e99b65b90 72a586ac_ceef_ac9f_17ec_0ed0d645b635["starlette.exceptions"] 01c652c5_d85c_f45e_848e_412c94ea4172 --> 72a586ac_ceef_ac9f_17ec_0ed0d645b635 20502214_d6d6_2052_679f_afae0f3867db["tutorial002_an_py310.py"] 20502214_d6d6_2052_679f_afae0f3867db --> 01c652c5_d85c_f45e_848e_412c94ea4172 9b55f91c_5e91_df2b_a4df_89a0d595abb7["tutorial002_an_py39.py"] 9b55f91c_5e91_df2b_a4df_89a0d595abb7 --> 01c652c5_d85c_f45e_848e_412c94ea4172 32cf0138_5dda_0a0d_8b8e_bf7910851ce9["tutorial002_py310.py"] 32cf0138_5dda_0a0d_8b8e_bf7910851ce9 --> 01c652c5_d85c_f45e_848e_412c94ea4172 7731c2d6_c29d_81ef_2e87_a0fd77fe47c8["tutorial002_py39.py"] 7731c2d6_c29d_81ef_2e87_a0fd77fe47c8 --> 01c652c5_d85c_f45e_848e_412c94ea4172 38ef6f23_808c_5f1f_4d60_57127dfa4be4["tutorial004_py39.py"] 38ef6f23_808c_5f1f_4d60_57127dfa4be4 --> 01c652c5_d85c_f45e_848e_412c94ea4172 608da54e_64a9_bb38_3bf3_fbbf45198033["tutorial005_py39.py"] 608da54e_64a9_bb38_3bf3_fbbf45198033 --> 01c652c5_d85c_f45e_848e_412c94ea4172 46d0b5a1_0a29_e7e1_5201_61b2c63c0e75["tutorial006_py39.py"] 46d0b5a1_0a29_e7e1_5201_61b2c63c0e75 --> 01c652c5_d85c_f45e_848e_412c94ea4172 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] 534f6e44_61b8_3c38_8b89_6934a6df9802 --> 01c652c5_d85c_f45e_848e_412c94ea4172 6c1867f2_34c4_b2ed_5639_41766e6fd7ce["applications.py"] 6c1867f2_34c4_b2ed_5639_41766e6fd7ce --> 01c652c5_d85c_f45e_848e_412c94ea4172 style 01c652c5_d85c_f45e_848e_412c94ea4172 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from collections.abc import Mapping, Sequence
from typing import Annotated, Any, Optional, TypedDict, Union
from annotated_doc import Doc
from pydantic import BaseModel, create_model
from starlette.exceptions import HTTPException as StarletteHTTPException
from starlette.exceptions import WebSocketException as StarletteWebSocketException
class EndpointContext(TypedDict, total=False):
function: str
path: str
file: str
line: int
class HTTPException(StarletteHTTPException):
"""
An HTTP exception you can raise in your own code to show errors to the client.
This is for client errors, invalid authentication, invalid data, etc. Not for server
errors in your code.
Read more about it in the
[FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/).
## Example
```python
from fastapi import FastAPI, HTTPException
app = FastAPI()
items = {"foo": "The Foo Wrestlers"}
@app.get("/items/{item_id}")
async def read_item(item_id: str):
if item_id not in items:
raise HTTPException(status_code=404, detail="Item not found")
return {"item": items[item_id]}
```
"""
def __init__(
self,
status_code: Annotated[
int,
Doc(
"""
HTTP status code to send to the client.
Read more about it in the
[FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/#use-httpexception)
"""
),
],
detail: Annotated[
Any,
Doc(
// ... (197 more lines)
Domain
Subdomains
Classes
Dependencies
- annotated_doc
- collections.abc
- pydantic
- starlette.exceptions
- typing
Imported By
- fastapi/__init__.py
- fastapi/applications.py
- fastapi/encoders.py
- fastapi/exception_handlers.py
- fastapi/security/http.py
- fastapi/security/oauth2.py
- fastapi/params.py
- fastapi/routing.py
- tests/test_custom_middleware_exception.py
- tests/test_dependency_yield_scope.py
- tests/test_dependency_yield_scope_websockets.py
- tests/test_empty_router.py
- tests/test_exception_handlers.py
- tests/test_filter_pydantic_sub_model_pv2.py
- tests/test_jsonable_encoder.py
- tests/test_pydantic_v1_error.py
- tests/test_regex_deprecated_body.py
- tests/test_regex_deprecated_params.py
- tests/test_response_model_as_return_annotation.py
- tests/test_response_model_invalid.py
- tests/test_schema_extra_examples.py
- tests/test_tutorial/test_response_model/test_tutorial003_04.py
- tests/test_tutorial/test_dependencies/test_tutorial008c.py
- tests/test_validate_response.py
- tests/test_validate_response_dataclass.py
- tests/test_validation_error_context.py
- docs_src/custom_request_and_route/tutorial002_an_py310.py
- docs_src/custom_request_and_route/tutorial002_an_py39.py
- docs_src/custom_request_and_route/tutorial002_py310.py
- docs_src/custom_request_and_route/tutorial002_py39.py
- docs_src/handling_errors/tutorial004_py39.py
- docs_src/handling_errors/tutorial005_py39.py
- docs_src/handling_errors/tutorial006_py39.py
- fastapi/utils.py
- fastapi/dependencies/utils.py
- fastapi/openapi/utils.py
Source
Frequently Asked Questions
What does exceptions.py do?
exceptions.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Routing subdomain.
What does exceptions.py depend on?
exceptions.py imports 5 module(s): annotated_doc, collections.abc, pydantic, starlette.exceptions, typing.
What files import exceptions.py?
exceptions.py is imported by 36 file(s): __init__.py, applications.py, encoders.py, exception_handlers.py, http.py, oauth2.py, params.py, routing.py, and 28 more.
Where is exceptions.py in the architecture?
exceptions.py is located at fastapi/exceptions.py (domain: FastAPI, subdomain: Routing, directory: fastapi).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free