瀏覽代碼

better exception logging

Rodja Trappe 2 年之前
父節點
當前提交
3f0ef589ab
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      nicegui/nicegui.py

+ 4 - 2
nicegui/nicegui.py

@@ -62,14 +62,16 @@ def shutdown() -> None:
 
 
 @app.exception_handler(404)
-async def exception_handler(_: Request, exception: Exception):
+async def exception_handler(r: Request, exception: Exception):
+    globals.log.warning(f'{r.url} not found')
     with Client(page('')) as client:
         error_content(404, exception)
     return client.build_response(404)
 
 
 @app.exception_handler(Exception)
-async def exception_handler(_: Request, exception: Exception):
+async def exception_handler(r: Request, exception: Exception):
+    globals.log.exception(f'unexpected exception for {r.url}', exception)
     with Client(page('')) as client:
         error_content(500, exception)
     return client.build_response(500)