Annotation Interface UnwrapException


@Retention(RUNTIME) @Target(TYPE) public @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:

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 Elements
    Modifier and Type
    Optional Element
    Description
    The unwrapping strategy to use for this exception.
    Class<? extends Exception>[]
    If this is not set, the value is assumed to be the exception class where the annotation is placed