Adding error 404 catcher

This commit is contained in:
Marcus Andersson 2021-05-13 00:08:15 +02:00 committed by Kevin Morris
parent 82f3871a83
commit cdf75ced9a
2 changed files with 22 additions and 0 deletions

14
aurweb/routers/errors.py Normal file
View file

@ -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,
}

View file

@ -0,0 +1,8 @@
{% extends 'partials/layout.html' %}
{% block pageContent %}
<div class="box 404">
<h2>404 - {% trans %}Page Not Found{% endtrans %}</h2>
<p>{% trans %}Sorry, the page you've requested does not exist.{% endtrans %}</p>
</div>
{% endblock %}