diff --git a/lnbits/app.py b/lnbits/app.py index b61880b64..81570b11d 100644 --- a/lnbits/app.py +++ b/lnbits/app.py @@ -6,7 +6,7 @@ import importlib import traceback import trio -from fastapi import FastAPI +from fastapi import FastAPI, Request from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.gzip import GZipMiddleware from fastapi.staticfiles import StaticFiles @@ -162,21 +162,13 @@ def register_async_tasks(app): async def stop_listeners(): pass +templates = Jinja2Templates(directory="templates") def register_exception_handlers(app): @app.errorhandler(Exception) - async def basic_error(err): + async def basic_error(request: Request, err): print("handled error", traceback.format_exc()) etype, value, tb = sys.exc_info() traceback.print_exception(etype, err, tb) exc = traceback.format_exc() - return ( - "\n\n".join( - [ - "LNbits internal error!", - exc, - "If you believe this shouldn't be an error please bring it up on https://t.me/lnbits", - ] - ), - 500, - ) + return await templates.TemplateResponse("templates/error.html", {"request": request, "err": err}) diff --git a/lnbits/templates/error.html b/lnbits/templates/error.html new file mode 100644 index 000000000..43a9ad8a5 --- /dev/null +++ b/lnbits/templates/error.html @@ -0,0 +1,36 @@ +{% extends "public.html" %} {% block page %} +
+
+ + +
+

Error

+
+ + +
{{ err }}
+

If you believe this shouldn't be an error please bring it up on https://t.me/lnbits

+
+
+
+
+
+ + {% endblock %} {% block scripts %} + + + + {% endblock %} +
\ No newline at end of file