Default error code to 500

[fixes #18]
master
Steven Loria 11 years ago
parent e3286524df
commit 5a4c4425f6
  1. 4
      {{cookiecutter.app_name}}/{{cookiecutter.app_name}}/app.py

@ -48,7 +48,9 @@ def register_blueprints(app):
def register_errorhandlers(app): def register_errorhandlers(app):
def render_error(error): 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]: for errcode in [401, 404, 500]:
app.errorhandler(errcode)(render_error) app.errorhandler(errcode)(render_error)
return None return None

Loading…
Cancel
Save