BAD REQUEST
+You're doing something you're not supposed to. Stop it?
+diff --git a/incorporealcms/__init__.py b/incorporealcms/__init__.py index 45ceb25..726eaa3 100644 --- a/incorporealcms/__init__.py +++ b/incorporealcms/__init__.py @@ -45,7 +45,10 @@ def create_app(instance_path=None, test_config=None): return send_from_directory(os.path.join(app.instance_path, app.config['MEDIA_DIR']), filename) - from . import pages + from . import error_pages, pages app.register_blueprint(pages.bp) + app.register_error_handler(400, error_pages.bad_request) + app.register_error_handler(404, error_pages.page_not_found) + app.register_error_handler(500, error_pages.internal_server_error) return app diff --git a/incorporealcms/error_pages.py b/incorporealcms/error_pages.py new file mode 100644 index 0000000..5034fab --- /dev/null +++ b/incorporealcms/error_pages.py @@ -0,0 +1,17 @@ +"""Error page views for 400, 404, etc.""" +from incorporealcms.lib import render + + +def bad_request(error): + """Display 400 error messaging.""" + return render('400.html'), 400 + + +def internal_server_error(error): + """Display 500 error messaging.""" + return render('500.html'), 500 + + +def page_not_found(error): + """Display 404 error messaging.""" + return render('404.html'), 404 diff --git a/incorporealcms/templates/400.html b/incorporealcms/templates/400.html new file mode 100644 index 0000000..5f629bf --- /dev/null +++ b/incorporealcms/templates/400.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} + +{% block header %} +
+{% endblock %} + +{% block body %} +You're doing something you're not supposed to. Stop it?
+Sorry, {{ request.path }} does not seem to exist, at least not anymore.
+It's possible you followed a dead link on this site, in which case I would appreciate it if you could email me via: + bss @ <this domain> and I can take a look. I make an effort to symlink old content to its new location, + so old links and URLs should, generally speaking, work.
+Otherwise, I suggest you go to the index and navigate your way (hopefully) to what + you're looking for.
+Something bad happened! Please email me at bss @ <this domain> and tell me what happened.
+