diff --git a/fabledscryer/app.py b/fabledscryer/app.py index 8cbfe64..397bb02 100644 --- a/fabledscryer/app.py +++ b/fabledscryer/app.py @@ -2,7 +2,7 @@ from __future__ import annotations import asyncio from pathlib import Path -from quart import Quart +from quart import Quart, render_template from .config import load_bootstrap from .database import init_db @@ -161,6 +161,15 @@ def create_app( async def health(): return {"status": "ok"} + # ── 12. Error handlers ───────────────────────────────────────────────────── + @app.errorhandler(404) + async def not_found(_): + return await render_template("errors/404.html"), 404 + + @app.errorhandler(500) + async def server_error(_): + return await render_template("errors/500.html"), 500 + # ── 11. Startup hook ─────────────────────────────────────────────────────── @app.before_serving async def startup(): diff --git a/fabledscryer/templates/errors/404.html b/fabledscryer/templates/errors/404.html new file mode 100644 index 0000000..1c7d700 --- /dev/null +++ b/fabledscryer/templates/errors/404.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} +{% block title %}Not Found — Fabled Scryer{% endblock %} +{% block content %} +
+

404

+

No such seat at this table.

+

The page you sought is not among us.

+ Return to the hall +
+{% endblock %} diff --git a/fabledscryer/templates/errors/500.html b/fabledscryer/templates/errors/500.html new file mode 100644 index 0000000..3e16334 --- /dev/null +++ b/fabledscryer/templates/errors/500.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} +{% block title %}Error — Fabled Scryer{% endblock %} +{% block content %} +
+

500

+

The watch has faltered.

+

An unexpected error occurred. The cause has been logged.

+ Return to the hall +
+{% endblock %}