Exceptions
default_404_exception_handler
default_404_exception_handler(request, exc)
Default 404 exception handler. Can be overloaded.
Returns:
| Type | Description |
|---|---|
AirResponse
|
An AirResponse with a 404 status code and error page. |
Example:
import air
app = air.Air()
@app.get("/")
def index() -> air.AirResponse:
return air.AirResponse(air.P("404 Not Found"), status_code=404)
Source code in src/air/exception_handlers.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
default_404_router_handler
default_404_router_handler(router_name)
Build an ASGI app that delegates the 404 to the default_404_exception_handler.
Returns:
| Type | Description |
|---|---|
ASGIApp
|
An ASGI application that handles 404 errors. |
Example:
import air
app = air.Air()
router = air.AirRouter()
@router.get("/example")
def index() -> air.AirResponse:
return air.AirResponse(air.P("I am an example route."), status_code=404)
app.include_router(router)
Source code in src/air/exception_handlers.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
default_500_exception_handler
default_500_exception_handler(request, exc)
Default 500 exception handler. Can be overloaded.
Returns:
| Type | Description |
|---|---|
AirResponse
|
An AirResponse with a 500 status code and error page. |
Example:
import air
app = air.Air()
@app.get("/")
def index() -> air.AirResponse:
return air.AirResponse(air.P("500 Internal Server Error"), status_code=500)
Source code in src/air/exception_handlers.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |