-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Cannot define a blueprint-specific exception handler #2202
Comments
Sorry for not responding earlier. I am looking at this. See also #2121 |
@ahopkins, I have tried the latest master, but it seems the test above still fails - the exception is still caught:/ |
@komar007 Well, I think you found an interesting use case that is not accounted for. In your use case above, the @handled.route("/ok")
def ok(request):
raise Error("error in e")
I am not 100% sure if this is even a legitimate use case: having a blueprint with no routes. The simple answer is to just ignore the assignment if there are no routes. |
Thanks, it works as expected. The code from the OP is indeed not a sensible use case, just the simplest reproduction path. |
See #2246 with a fix to this. |
Describe the bug
The documentation at https://sanicframework.org/en/guide/best-practices/blueprints.html#exceptions says that:
However, exception handlers defined this way don't seem to be blueprint-specific at all. Instead, they handle exceptions in other blueprints as well.
Code snippet
Expected behavior
A request to http://localhost:8000 should generate 500, because
Error
should not be handled.Instead, the request generates 200,
Error
is handled, even though the handler is registered inhandled
, while the endpoint is inb
.Environment (please complete the following information):
Additional context
The order of blueprint registration does not seem to change anything. Not registering blueprint
handled
obviously fixes the issue.Is it a bug or am I missing something here?
The text was updated successfully, but these errors were encountered: