Browse Source

add 404 error page

Falko Schindler 2 years ago
parent
commit
8178e9e144
1 changed files with 5 additions and 0 deletions
  1. 5 0
      nicegui/nicegui.py

+ 5 - 0
nicegui/nicegui.py

@@ -60,6 +60,11 @@ def shutdown() -> None:
     globals.state = globals.State.STOPPED
 
 
+@app.exception_handler(404)
+async def exception_handler(_: Request, exc: Exception):
+    return error_client.build_response(404, str(exc))
+
+
 @app.exception_handler(Exception)
 async def exception_handler(_: Request, exc: Exception):
     return error_client.build_response(500, str(exc))