Skip to content

Conversation

@taion
Copy link
Contributor

@taion taion commented Nov 1, 2018

Fixes #2984

@davidism
Copy link
Member

davidism commented Nov 1, 2018

Yeah, this makes sense now.

@taion

This comment has been minimized.

@davidism
Copy link
Member

davidism commented Jan 7, 2019

I did a little more research just to make sure I understood what changed from 0.12 to 1.0, in case we need to address this again later.

Prior to 1.0, error handlers for HTTPException classes were only looked up by code. So if there wasn't a specific handler registered, it wouldn't fall back to a more general handler, which people found confusing. But it was possible to add a handler specifically for the 301 code and have different redirect behavior. Why you would do that, I don't know, but it was possible. And since RequestRedirect wasn't part of the werkzeug.exceptions.default_exceptions map, a handler for 301 wouldn't have matched it anyway.

I'm OK with saying that anyone who really wants to catch RequestRedirect should override handle_http_exception or url_map to do something different. Or if they want to redirect using exceptions, they can create their own class Found(HTTPException): code = 302 and add a handler for that.

@davidism davidism added this to the 1.0.3 milestone Jan 7, 2019
@davidism davidism changed the base branch from master to 1.0-maintenance January 7, 2019 17:54
@davidism davidism force-pushed the do-not-handle-routing-exception branch from f9f6e78 to 662ce21 Compare January 7, 2019 17:54
@davidism davidism changed the title [RFC] Do not handle RoutingExceptions with app error handlers Do not handle RoutingExceptions with app error handlers Jan 7, 2019
@davidism davidism merged commit ded7cbe into pallets:1.0-maintenance Jan 7, 2019
@taion taion deleted the do-not-handle-routing-exception branch January 7, 2019 18:05
@taion
Copy link
Contributor Author

taion commented Jan 7, 2019

Or if they want to redirect using exceptions, they can create their own class Found(HTTPException): code = 302 and add a handler for that.

One small comment on the above – if someone does want to redirect using exceptions in a view, they wouldn't use RequestRedirect anyway. It's documented as a thing to use inside Werkzeug routing.

Because RoutingException is not actually part of werkzeug.exceptions.default_exceptions, installing an exception handler for 302 (well, now it's 308) in 0.12 would not have caught RoutingExceptions anyway.

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