ControllerAdvice/ExceptionHandler do not apply to non reactive RouterFunction #41005
Labels
for: external-project
For an external project and not something we can fix
for: stackoverflow
A question that's better suited to stackoverflow.com
status: invalid
An issue that we don't feel is valid
I have set up a small spring boot application to test a use case where the global exception handling feature through
@ControllerAdvice
and@ExceptionHandler
does not work for any non reactive RouterFunction definitions.While I am able to see the controller advice being activated when testing the controller mappings (
ApplicationController.java
below), when an exception is thrown from inside a handler class/method for a RouterFunction,AbstractHandlerExceptionResolver
(most likely because the return type of the mapping is notResponseEntity
) fails to resolve the exception, thus returningThere was an unexpected error (type=Internal Server Error, status=500).
The expectation was that by hitting the endpoint
/fn/custom
the resulting response would be HttpStatus BAD_REQUEST, instead of Internal Server ErrorSteps to reproduce:
Using the latest version from start.spring.io
@ControllerAdvice
RounterFunction configuration:
Controller specification
Custom exception:
Console output for
/fn/custom
If this is not an issue, I am seeking for an alternative solution where we can apply a global exception handler for non reactive RouterFunction using the following classes:
The text was updated successfully, but these errors were encountered: