From 866077830070739191e7e21bc471870efd8bb9bf Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 14 Jan 2021 19:06:00 -0800 Subject: fastapi: add basic error/exception handler and page --- fatcat_scholar/templates/error.html | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 fatcat_scholar/templates/error.html (limited to 'fatcat_scholar/templates/error.html') diff --git a/fatcat_scholar/templates/error.html b/fatcat_scholar/templates/error.html new file mode 100644 index 0000000..2eafa8d --- /dev/null +++ b/fatcat_scholar/templates/error.html @@ -0,0 +1,31 @@ +{% extends "base.html" %} + +{% block title %} +{{ error.status_code }} - {{ super() }} +{% endblock %} + +{% block main %} +
+
{{ error.status_code }}
+
+ {% if error.status_code == 404 %} + {% trans %}Not Found{% endtrans %} + {% elif error.status_code == 403 %} + {% trans %}Access Forbidden{% endtrans %} + {% elif error.status_code == 400 %} + {% trans %}Request Error{% endtrans %} + {% elif error.status_code > 500 and error.status_code < 600 %} + {% trans %}Internal Error{% endtrans %} + {% endif %} +
+
+{% if error.detail and error.detail not in ["Not Found", "Server Error", "Bad Request"] %} +
+ +
+
+

{{ error.detail }} +

+
+{% endif %} +{% endblock %} -- cgit v1.2.3