From 5a4c4425f6bc0557c1dcc0167ce4065c7ef95b40 Mon Sep 17 00:00:00 2001 From: Steven Loria Date: Sat, 10 May 2014 09:38:41 -0500 Subject: [PATCH] Default error code to 500 [fixes #18] --- {{cookiecutter.app_name}}/{{cookiecutter.app_name}}/app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.app_name}}/{{cookiecutter.app_name}}/app.py b/{{cookiecutter.app_name}}/{{cookiecutter.app_name}}/app.py index 66209c1..47901f5 100644 --- a/{{cookiecutter.app_name}}/{{cookiecutter.app_name}}/app.py +++ b/{{cookiecutter.app_name}}/{{cookiecutter.app_name}}/app.py @@ -48,7 +48,9 @@ def register_blueprints(app): def register_errorhandlers(app): def render_error(error): - return render_template("{0}.html".format(error.code)), error.code + # If a HTTPException, pull the `code` attribute; default to 500 + error_code = getattr(error, 'code', 500) + return render_template("{0}.html".format(error_code)), error_code for errcode in [401, 404, 500]: app.errorhandler(errcode)(render_error) return None