'SpringBoot @ExceptionHandler bubbles to Exception

I'm using Kotlin and SpringBoot 2.3. While testing I realized that @ExceptionHandler(MissingKotlinParameterException::class) in my controller doesn't work if I have an generic handler for uncaught exceptions with @ExceptionHandler(Exception::class).

The exception always bubbles to generic exception handler. It's not the case with other exceptions like IllegalArgumentsException which the correct handler handles.

Anyone knows what am I missing?

Thanks



Solution 1:[1]

Use @ExceptionHandler(HttpMessageNotReadableException::class)

instead of @ExceptionHandler(MissingKotlinParameterException::class)

I had the same issue but with this above I solved the problem.

It is something to do with wrapper.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Doo Hyun Shin