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