problem-spring-web icon indicating copy to clipboard operation
problem-spring-web copied to clipboard

Functional route support

Open tomirio619 opened this issue 5 years ago • 8 comments

I am using Spring Webflux with functional routes in Kotlin. When following the steps to configure Zalando Problem for WebFlux, and throw a Problem in my handler, the error response is the default Spring Boot response instead of the expected Problem response.

I'm not sure why this is the case, or if I'm missing something. I created a repository that contains a minimal example

Edit: I mistakenly linked to the wrong repo, which I fixed

tomirio619 avatar Feb 02 '20 11:02 tomirio619

Functional routes are currently not supported by this lib.

cbornet avatar Feb 02 '20 14:02 cbornet

Is this something to be expected in a future release? The handle method in the ProblemExceptionHandler currently checks if the throwable is an instance of ResponseStatusException, and if so transforms this to an ResponseEntity<Problem>>. With my limited knowledge of the source code, would adding an additional condition that verifies that the throwable is an instance of Problem solve my problem?

tomirio619 avatar Feb 02 '20 15:02 tomirio619

That would probably work. Ultimately the best would be to check if a registered ExceptionHandler can handle the exception like what is done with Controller advice.

cbornet avatar Feb 02 '20 17:02 cbornet

I've done something similar here. Maybe that could be done for that also.

cbornet avatar Feb 02 '20 17:02 cbornet

That would solve the problem indeed! Any idea when it will be merged?

tomirio619 avatar Feb 03 '20 07:02 tomirio619

#400 is missing some coverage, if I'm not mistaken

whiskeysierra avatar Feb 03 '20 08:02 whiskeysierra

I know 😰. Note that it won't fix this issue. It's just related.

cbornet avatar Feb 03 '20 11:02 cbornet

It would right, the updated handle method would now search for the corresponding default interface method that can handle that specific exception, and invoke it.

tomirio619 avatar Feb 03 '20 12:02 tomirio619