From cdf75ced9abe855753e33b48cc869c4ac64506ba Mon Sep 17 00:00:00 2001 From: Marcus Andersson Date: Thu, 13 May 2021 00:08:15 +0200 Subject: [PATCH] Adding error 404 catcher --- aurweb/routers/errors.py | 14 ++++++++++++++ templates/errors/404.html | 8 ++++++++ 2 files changed, 22 insertions(+) create mode 100644 aurweb/routers/errors.py create mode 100644 templates/errors/404.html diff --git a/aurweb/routers/errors.py b/aurweb/routers/errors.py new file mode 100644 index 00000000..5d4ca4ce --- /dev/null +++ b/aurweb/routers/errors.py @@ -0,0 +1,14 @@ +from aurweb.templates import make_context, render_template +from aurweb import l10n + + +async def not_found(request, exc): + _ = l10n.get_translator_for_request(request) + context = make_context(request, f"404 - {_('Page Not Found')}") + return render_template("errors/404.html", context) + + +# Maps HTTP errors to functions +exceptions = { + 404: not_found, +} diff --git a/templates/errors/404.html b/templates/errors/404.html new file mode 100644 index 00000000..0afdd2fa --- /dev/null +++ b/templates/errors/404.html @@ -0,0 +1,8 @@ +{% extends 'partials/layout.html' %} + +{% block pageContent %} +
+

404 - {% trans %}Page Not Found{% endtrans %}

+

{% trans %}Sorry, the page you've requested does not exist.{% endtrans %}

+
+ {% endblock %}