Exceptions
default_404_exception_handler
default_404_exception_handler(request, exc)
Default 404 exception handler. Can be overloaded.
Example:
import air
app = air.Air()
@app.get("/")
def index():
return air.AirResponse(air.P("404 Not Found"), status_code=404)
Source code in src/air/exception_handlers.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
default_404_router_handler
default_404_router_handler(router_name)
Build an ASGI app that delegates the 404 to the default_404_exception_handler.
Example:
import air
app = air.Air()
router = air.AirRouter()
@router.get("/example")
def index():
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 | |
default_500_exception_handler
default_500_exception_handler(request, exc)
Default 500 exception handler. Can be overloaded.
Example:
import air
app = air.Air()
@app.get("/")
def index():
return air.AirResponse(air.P("500 Internal Server Error"), status_code=500)
Source code in src/air/exception_handlers.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |