Skip to content

Fix #941 -- allow errorhandlers for HTTPException - #952

Closed
untitaker wants to merge 1 commit into
pallets:masterfrom
untitaker:error_handling
Closed

untitaker wants to merge 1 commit into
pallets:masterfrom
untitaker:error_handling

Conversation

@untitaker

Copy link
Copy Markdown
Contributor

Originally i intended to rewrite the error handling system to register an
error handler for each subclass of HTTPException on initialization of the
Flask object, removing the distinction between HTTP exceptions and other
exception types. However, with the current behavior of preferring the
first-registered handler when an error occurs, doing this without compromises
would require changing this to preferring the last-registered handler, a
backwards-incompatible change.

The following is a very minimal fix to only make Flask prioritize the user's
error handlers over others. I am not sure which performance implications this
has. Maybe a major rewrite of the error handling system is still desirable
(with more complex prioritization of errorhandlers -- something based on
"distance" in inheritance tree?), but at the moment i don't see a reason to do
so, given that the current system is primitive enough to be understandable,
while still usable.

@mbr

mbr commented Jan 17, 2014

Copy link
Copy Markdown

I'm in need of the same feature (and currently using a crude workaround), I'd love to see this fixed/merged.

Originally i intended to rewrite the error handling system to register
an error handler for each subclass of HTTPException on initialization
of the Flask object, removing the distinction between HTTP exceptions
and other exception types. However, with the current behavior of
preferring the first-registered handler when an error occurs, doing this
without compromises would require changing this to preferring the
last-registered handler, a backwards-incompatible change.

The following is a very minimal fix to only make Flask prioritize the
user's error handlers over others. I am not sure which performance
implications this has. Maybe a major rewrite of the error handling
system is still desirable (with more complex prioritization of
errorhandlers -- something based on "distance" in inheritance tree?),
but at the moment i don't see a reason to do so, given that the current
system is primitive enough to be understandable, while still usable.
@untitaker

Copy link
Copy Markdown
Contributor Author

Bump.

@untitaker

Copy link
Copy Markdown
Contributor Author

It seems like i duplicated #839 without realizing.

@untitaker untitaker closed this Mar 26, 2014
@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