From 50a2774a02993b36838e4672d395a314233c4f16 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 31 Jan 2019 18:02:31 -0800 Subject: better flask error pages --- python/fatcat_web/routes.py | 19 +++++++++++++++++++ python/fatcat_web/templates/403.html | 15 +++++++++++++++ python/fatcat_web/templates/404.html | 5 ++++- python/fatcat_web/templates/409.html | 13 +++++++++++++ python/fatcat_web/templates/500.html | 13 +++++++++++++ python/fatcat_web/templates/503.html | 12 ++++++++++++ 6 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 python/fatcat_web/templates/403.html create mode 100644 python/fatcat_web/templates/409.html create mode 100644 python/fatcat_web/templates/500.html create mode 100644 python/fatcat_web/templates/503.html diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index 21f81eae..d712be01 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -429,6 +429,25 @@ def auth_account(): def page_not_found(e): return render_template('404.html'), 404 +@app.errorhandler(401) +@app.errorhandler(403) +def page_not_authorized(e): + return render_template('403.html'), 403 + +@app.errorhandler(409) +def page_edit_conflict(e): + return render_template('409.html'), 409 + +@app.errorhandler(500) +def page_server_error(e): + return render_template('500.html'), 500 + +@app.errorhandler(502) +@app.errorhandler(503) +@app.errorhandler(504) +def page_server_down(e): + return render_template('503.html'), 503 + @app.route('/', methods=['GET']) def homepage(): return render_template('home.html') diff --git a/python/fatcat_web/templates/403.html b/python/fatcat_web/templates/403.html new file mode 100644 index 00000000..14c31bb2 --- /dev/null +++ b/python/fatcat_web/templates/403.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} +{% block body %} + +
+
403
+
Not Authorized
+ +

You might need to log in, or your account may not (yet!) have privileges to +complete the attempted action. + +

This could also just mean that you need to log out and log back in. Sorry +about that! +

+ +{% endblock %} diff --git a/python/fatcat_web/templates/404.html b/python/fatcat_web/templates/404.html index c8fbfeac..653b8eed 100644 --- a/python/fatcat_web/templates/404.html +++ b/python/fatcat_web/templates/404.html @@ -1,6 +1,9 @@ {% extends "base.html" %} {% block body %} -

404: Not Found

+
+
404
+
Not Found
+
{% endblock %} diff --git a/python/fatcat_web/templates/409.html b/python/fatcat_web/templates/409.html new file mode 100644 index 00000000..4f56e03e --- /dev/null +++ b/python/fatcat_web/templates/409.html @@ -0,0 +1,13 @@ +{% extends "base.html" %} +{% block body %} + +
+
409
+
Edit Conflict
+ +

Oops! Somebody else tried to edit the same resource at the same time, and +there was a conflict. You will need to resolve this manually (eg, create a new +edit from scratch). +

+ +{% endblock %} diff --git a/python/fatcat_web/templates/500.html b/python/fatcat_web/templates/500.html new file mode 100644 index 00000000..a99232cb --- /dev/null +++ b/python/fatcat_web/templates/500.html @@ -0,0 +1,13 @@ +{% extends "base.html" %} +{% block body %} + +
+
500
+
Internal Error
+ +

Hrm, something unexpected went wrong. You may have found a bug! This request +should be logged and reported automatically; you could re-try or contact us for +more info. +

+ +{% endblock %} diff --git a/python/fatcat_web/templates/503.html b/python/fatcat_web/templates/503.html new file mode 100644 index 00000000..f21afacc --- /dev/null +++ b/python/fatcat_web/templates/503.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{% block body %} + +
+
503
+
Server Error
+ +

Hrm, something unexpected went wrong with a back-end service. Check the +status link below, and try again later. Apologies! +

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