Annotation Interface UnwrapException
Used to configure that an exception (or exceptions) should be unwrapped during exception handling.
Unwrapping means that when an Exception of the configured type is thrown,
RESTEasy Reactive will attempt to locate an ExceptionMapper for the cause of the Exception.
The unwrapping behavior is controlled by the strategy() attribute:
ExceptionUnwrapStrategy.ALWAYS: Always unwraps before checking mappers. Only falls back to checking mappers for the wrapper if no mapper is found for any unwrapped cause.ExceptionUnwrapStrategy.UNWRAP_IF_NO_EXACT_MATCH: Unwraps only if the thrown exception type itself has no exact mapper. Checks for exact match first, then unwraps if none found.ExceptionUnwrapStrategy.UNWRAP_IF_NO_MATCH(default): Unwraps only if neither the thrown exception nor any of its supertypes have a registered mapper.
Example:
@UnwrapException(value = { WebApplicationException.class }, strategy = ExceptionUnwrapStrategy.UNWRAP_IF_NO_EXACT_MATCH)
public class ExceptionsMappers {
@ServerExceptionMapper
public RestResponse<Error> mapUnhandledException(RuntimeException ex) {
// Handles RuntimeException and its subclasses
}
@ServerExceptionMapper
public RestResponse<Error> mapJsonProcessingException(JsonProcessingException ex) {
// This will be called for JsonProcessingException wrapped in WebApplicationException
// because UNWRAP_IF_NO_EXACT_MATCH forces unwrapping even though RuntimeException mapper exists
}
}
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe unwrapping strategy to use for this exception.If this is not set, the value is assumed to be the exception class where the annotation is placed
-
Element Details
-
value
If this is not set, the value is assumed to be the exception class where the annotation is placed- Default:
{}
-
strategy
ExceptionUnwrapStrategy strategyThe unwrapping strategy to use for this exception.Defaults to
ExceptionUnwrapStrategy.UNWRAP_IF_NO_MATCH.- Default:
UNWRAP_IF_NO_MATCH
-