Describe the bug
I mapped a checked exception to a specific mapper, but it is not called when a use case throws the exception. Instead, the default exception handler is called with an exception of type
com.envimate.messageMate.useCases.useCasesAdapter.methodInvoking.MethodInvocationException
To Reproduce
Setup an application exception mapper next to the default exception mapper, for a checked application exception (it only happens with checked exceptions)
public class ApplicationException extends Exception {
...
}
.configured(toMapExceptions()
.ofType(ApplicationException.class).toResponsesUsing(caughtExceptionMapper)
.ofAllRemainingTypesUsing(uncaughtExceptionMapper)
Cause the exception to occur in the invoked use case
public Response invoke(
final Requet request)
throws ApplicationException {
...
return optional.orElseThrow(ApplicationException.class);
}
The uncaughtExceptionHandler is called with
com.envimate.messageMate.useCases.useCaseAdapter.methodInvoking.MethodInvocationException: Could not call method public ...
-> cause: java.lang.reflect.InvocationTargetException
-> target: ...ApplicationException
Expected behavior
The caughtExceptionMapper should be called.
I masked my real class names, but please do ask if you need more details.