I want to catch and log every exception thrown in my application, so I made:
@ExceptionHandler(Exception.class)
public ResponseEntity<Problem> handleDefault(){
(yes I will convert it into a problem).
It works, but does not take into account any runtime exception such as NullPointer. So I decided to go further:
@ExceptionHandler(Throwable.class)
public ResponseEntity<Problem> handleDefault(){
But it seems that it is not possible as spring already defines one:
Caused by: java.lang.IllegalStateException: Ambiguous @ExceptionHandler method mapped for [class java.lang.Throwable]: {public org.springframework.http.ResponseEntity com.foo.exception.handlers.MyExceptionHandler.handleDefault(), public default org.springframework.http.ResponseEntity org.zalando.problem.spring.web.advice.general.ThrowableAdviceTrait.handleThrowable(java.lang.Throwable,org.springframework.web.context.request.NativeWebRequest)}