-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
Check error handlers for classes before HTTP status codes #839
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
Conversation
|
👍 |
|
Idea and execution looks good to me. Can you add tests though? |
|
Eh, nevermind :P I guess i meant changelog entry. |
|
To /CHANGES? Which heading would you like me to add it under? |
|
Yes, to |
|
I don't know if @mitsuhiko has anything against this change though. He is the one who makes decisions. |
|
This isn't a bugfix so it's not going to land in 0.10.2. If it gets merged, it will be in 1.0 (because there won't be a 0.11.) |
|
I thought it'd be sensible because from what i can remember smaller behavior changes have been added to bugfix releases. Can't recall if it was Werkzeug or Flask though. |
|
I still don't think it's a good idea though, unless there is a very good reason for it. This definitely isn't one. |
This allows adding error handlers like this:
@app.errorhandler(werkzeug.exceptions.Forbidden)
And subclassing HTTPExceptions:
class ForbiddenBecauseReason(Forbidden): pass
@app.errorhandler(ForbiddenBecauseReason)
def error1(): return "Forbidden because reason", 403
@app.errorhandler(403)
def error2(): return "Forbidden", 403
... the idea being, that a flask extension might want to raise an
exception, with the default behaviour of creating a HTTP error page,
but still allowing the user to add a view/handler specific to that
exception (e.g., "Forbidden because you are not in the right group").
|
CHANGES entry added |
|
Looks like a good idea to me |
|
Merged finally. It's a good idea. |
This allows adding error handlers like this:
@app.errorhandler(werkzeug.exceptions.Forbidden)And subclassing HTTPExceptions:
... the idea being, that a flask extension might want to raise an exception, with the default behaviour of creating a HTTP error page, but still allowing the user to add a view/handler specific to that exception (e.g., "Forbidden because you are not in the right group").