Skip to content

Error handler support for generic HttpException - #2082

Closed
gcetusic wants to merge 2 commits into
pallets:masterfrom
gcetusic:master
Closed

gcetusic wants to merge 2 commits into
pallets:masterfrom
gcetusic:master

Conversation

@gcetusic

@gcetusic gcetusic commented Nov 9, 2016 •

Copy link
Copy Markdown

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

jeffwidman commented May 23, 2017 •

Copy link
Copy Markdown
Contributor

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