Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass through error messages to templates #56

Merged
merged 2 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.0.2 (2022-03-21)

Pass through error messages from flask.abort to 404.html and 500.html templates

# 1.0.1 (2022-02-21)

Fix dependencies for Flask 1.1.x: markupsafe and itsdangerous.
Expand Down
14 changes: 12 additions & 2 deletions canonicalwebteam/flask_base/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,23 @@ def __init__(

@self.errorhandler(404)
def not_found_error(error):
return flask.render_template(template_404), 404
return (
flask.render_template(
template_404, message=error.description
),
404,
)

if template_500:

@self.errorhandler(500)
def internal_error(error):
return flask.render_template(template_500), 500
return (
flask.render_template(
template_500, message=error.description
),
500,
)

# Default routes
@self.route("/fish")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name="canonicalwebteam.flask-base",
version="1.0.1",
version="1.0.2",
description=(
"Flask extension that applies common configurations"
"to all of webteam's flask apps."
Expand Down