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

Error handler support for generic HttpException #2082

Closed
wants to merge 2 commits into from

Conversation

gcetusic
Copy link

@gcetusic gcetusic commented Nov 9, 2016

Flask supports setting HttpException as error handler class:

app.register_error_handler(HTTPException, lambda error: jsonify(error=error.code, text=str(error)))

This fills error_handler_spec with something like this for any blueprint {None: {None: lambda_function}}

However, when finding the error handler it checks the error code which is e.g. 404 and ignores None, the error handler for any error, previously set by register_error_handler. It doesn't find 404, doesn't check for None in the dict and falls back to the default error handler which shouldn't happen.

cerickson added a commit to cerickson/flask that referenced this pull request May 22, 2017
Error handlers are now returned in order of blueprint:code, app:code,
blueprint:HTTPException, app:HTTPException, None

Corresponding tests also added.

Ref issue pallets#941, pr pallets#1383, pallets#2082, pallets#2144
@jeffwidman
Copy link
Contributor

jeffwidman commented May 23, 2017

Thanks for this. Closing in favor of #2304 which is a more extensive solution to this.

@jeffwidman jeffwidman closed this May 23, 2017
cerickson added a commit to cerickson/flask that referenced this pull request May 23, 2017
Error handlers are now returned in order of blueprint:code, app:code,
blueprint:HTTPException, app:HTTPException, None

Corresponding tests also added.

Ref issue pallets#941, pr pallets#1383, pallets#2082, pallets#2144
cerickson added a commit to cerickson/flask that referenced this pull request May 23, 2017
Error handlers are now returned in order of blueprint:code, app:code,
blueprint:HTTPException, app:HTTPException, None

Corresponding tests also added.

Ref issue pallets#941, pr pallets#1383, pallets#2082, pallets#2144
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants