-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Allow @ControllerAdvice
in WebFlux to handle exceptions before a handler is selected
#22991
Comments
I found another way to do this, using
I delegated the exception to the |
An As you are in a Spring Boot application there are options to customize error handling at that level. |
I'm having the same issue I was expecting the spring framework to be agnostic of the server and I could centralize the exception handling from my ControllerAdvice as @wangxing-git mentioned we can do that when running the application with tomcat. Is there a way to bring this convenience to the framework? |
The handling of exceptions before a controller method is selected is a relatively recent Spring MVC feature, added in 5.3 with #22619. We could align the two and provide an equivalent feature in WebFlux. |
@ControllerAdvice
in WebFlux to handle exceptions before a handler is selected
Given the new addition of ResponseEntityExceptionHandler as a part of #27052 I would expect there this to work. As of the moment I can't get a subclass (annotated with ContollerAdvice) to handle exceptions like method not supported even though the code implies this should work. Maybe be missing a configuration item though... |
Commit #2878ad added the DispatchExceptionHandler contract for mapping an error before a handler is selected to a HandlerResult. The same is also convenient for use in HandlerResult itself which currently uses a java.util.Function essentially for the same. See gh-22991
Hi, this is still happening with a 404 as it comes back with the original response:
I would have thought this would have been fixed with 307247b is the intended behaviour? |
Odd, we have a test for that. |
Ah I see, that is not what is being displayed. Do you want a zip project file with the issue? |
Sure, or a github repo. |
Affects: 5.1.7.RELEASE
When I tried to handle the http
405
error with@ExceptionHandler
I found that I couldn't catch theMethodNotAllowedException
exception inwebflux
, which can be done in theweb mvc
by catching theHttpRequestMethodNotSupportedException
exception. Is this a bug or is it not supported or is there another way to do it?The text was updated successfully, but these errors were encountered: