Repository navigation
Check error handlers for classes before HTTP status codes - #839
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").