Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 901
zhaider Avatar asked Apr 27 '26 10:04

zhaider


1 Answers

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.

like image 67
Doo Hyun Shin Avatar answered Apr 30 '26 04:04

Doo Hyun Shin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!