public final class ExceptionUtil extends Object
| Modifier and Type | Class and Description | 
|---|---|
| static interface  | ExceptionUtil.ExceptionWrapper<T extends Throwable>Interface used by rethrow/peel to wrap the peeled exception | 
| Modifier and Type | Method and Description | 
|---|---|
| static void | fixAsyncStackTrace(Throwable asyncCause,
                  StackTraceElement[] localSideStackTrace)This method changes the given async cause, and it adds the also given local stacktrace. If the remoteCause is an ExecutionExceptionand it has a non-null inner
 cause, this inner cause is unwrapped and the local stacktrace and exception message are added to the
 that instead of the given asyncCause itself. | 
| static void | fixAsyncStackTrace(Throwable asyncCause,
                  StackTraceElement[] localSideStackTrace,
                  String localExceptionMessage)This method changes the given async cause, and it adds the also given local stacktrace separated by the
 supplied exception message. If the remoteCause is an ExecutionExceptionand it has a non-null inner
 cause, this inner cause is unwrapped and the local stacktrace and exception message are added to the
 that instead of the given remoteCause itself. | 
| static RuntimeException | peel(Throwable t) | 
| static <T extends Throwable> | peel(Throwable t,
    Class<T> allowedType,
    String message)Processes  Throwable tso that the returnedThrowable's type matchesallowedTypeorRuntimeException. | 
| static <T,W extends Throwable> | peel(Throwable t,
    Class<T> allowedType,
    String message,
    ExceptionUtil.ExceptionWrapper<W> exceptionWrapper)Processes  Throwable tso that the returnedThrowable's type matchesallowedType,RuntimeExceptionor anyThrowablereturned by `exceptionWrapper`
 Processing may include unwrappingt's cause hierarchy, wrapping it in a exception
 created by using exceptionWrapper or just returning the same instancetif it is already an instance ofRuntimeException. | 
| static RuntimeException | rethrow(Throwable t) | 
| static <T extends Throwable> | rethrow(Throwable t,
       Class<T> allowedType) | 
| static RuntimeException | rethrow(Throwable t,
       ExceptionUtil.ExceptionWrapper<RuntimeException> exceptionWrapper) | 
| static <T extends Throwable> | rethrowAllowedTypeFirst(Throwable t,
                       Class<T> allowedType)This rethrow the exception providing an allowed Exception in first priority, even it is a Runtime exception | 
| static RuntimeException | rethrowAllowInterrupted(Throwable t) | 
| static <T> T | sneakyThrow(Throwable t) | 
| static String | toString(Throwable cause)Converts a Throwable stacktrace to a String. | 
| static <T extends Throwable> | tryCreateExceptionWithMessageAndCause(Class<? extends Throwable> exceptionClass,
                                     String message,
                                     Throwable cause)Tries to create the exception with appropriate constructor in the following order. | 
public static String toString(Throwable cause)
cause - the Throwablepublic static RuntimeException peel(Throwable t)
public static <T extends Throwable> Throwable peel(Throwable t, Class<T> allowedType, String message)
Throwable t so that the returned Throwable's type matches allowedType or
 RuntimeException. Processing may include unwrapping t's cause hierarchy, wrapping it in a
 HazelcastException or just returning the same instance t if it is already an instance of
 RuntimeException.T - expected type of Throwablet - Throwable to be peeledallowedType - the type expected to be returned; when null, this method returns instances
                    of RuntimeExceptionmessage - if not null, used as the message in the HazelcastException that
                    may wrap the peeled ThrowableThrowablepublic static <T,W extends Throwable> Throwable peel(Throwable t, Class<T> allowedType, String message, ExceptionUtil.ExceptionWrapper<W> exceptionWrapper)
Throwable t so that the returned Throwable's type matches allowedType,
 RuntimeException or any Throwable returned by `exceptionWrapper`
 Processing may include unwrapping t's cause hierarchy, wrapping it in a exception
 created by using exceptionWrapper or just returning the same instance t
 if it is already an instance of RuntimeException.W - Type of the wrapper exception in exceptionWrapperT - allowed type of Throwablet - Throwable to be peeledallowedType - the type expected to be returned; when null, this method returns instances
                         of RuntimeException or message - if not null, used as the message in RuntimeException that
                         may wrap the peeled ThrowableexceptionWrapper - wraps the peeled code using this exceptionWrapperThrowablepublic static RuntimeException rethrow(Throwable t)
public static RuntimeException rethrow(Throwable t, ExceptionUtil.ExceptionWrapper<RuntimeException> exceptionWrapper)
public static <T extends Throwable> RuntimeException rethrow(Throwable t, Class<T> allowedType) throws T extends Throwable
T extends Throwablepublic static <T extends Throwable> RuntimeException rethrowAllowedTypeFirst(Throwable t, Class<T> allowedType) throws T extends Throwable
T extends Throwablepublic static RuntimeException rethrowAllowInterrupted(Throwable t) throws InterruptedException
InterruptedExceptionpublic static <T> T sneakyThrow(Throwable t)
public static void fixAsyncStackTrace(Throwable asyncCause, StackTraceElement[] localSideStackTrace)
ExecutionException and it has a non-null inner
 cause, this inner cause is unwrapped and the local stacktrace and exception message are added to the
 that instead of the given asyncCause itself.asyncCause - the async exceptionlocalSideStackTrace - the local stacktrace to add to the exception stacktracepublic static void fixAsyncStackTrace(Throwable asyncCause, StackTraceElement[] localSideStackTrace, String localExceptionMessage)
ExecutionException and it has a non-null inner
 cause, this inner cause is unwrapped and the local stacktrace and exception message are added to the
 that instead of the given remoteCause itself.asyncCause - the async exceptionlocalSideStackTrace - the local stacktrace to add to the exceptions stacktracelocalExceptionMessage - a special exception message which is added to the stacktracepublic static <T extends Throwable> T tryCreateExceptionWithMessageAndCause(Class<? extends Throwable> exceptionClass, String message, @Nullable Throwable cause)
initCause)
 new Throwable(String message, Throwable cause)
 new Throwable(Throwable cause)
 new Throwable(String message)
 new Throwable()exceptionClass - class of the exceptionmessage - message to be pass to constructor of the exceptioncause - cause to be set to the exceptionnull if can not find a constructor as described above, otherwise returns newly constructed exceptionCopyright © 2022 Hazelcast, Inc.. All Rights Reserved.