Class ThrowableUtils
- java.lang.Object
-
- io.servicetalk.concurrent.internal.ThrowableUtils
-
public final class ThrowableUtils extends java.lang.ObjectUtility for creating staticThrowables.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.ThrowablecatchUnexpected(java.lang.Throwable delayedCause, java.lang.Throwable cause)Used in scenarios where multiple operations which aren't expected to throw but exception propagation must be delayed to preserve control flow.static booleanmatches(java.lang.Throwable original, java.lang.Class<? extends java.lang.Throwable> toMatch)Finds if the passedoriginalor any of its causes are an instance oftoMatch.static <T extends java.lang.Throwable>
TunknownStackTrace(T cause, java.lang.Class<?> clazz, java.lang.String method)Set theStackTraceElementfor the givenThrowable, using theClassand method name.
-
-
-
Method Detail
-
unknownStackTrace
public static <T extends java.lang.Throwable> T unknownStackTrace(T cause, java.lang.Class<?> clazz, java.lang.String method)Set theStackTraceElementfor the givenThrowable, using theClassand method name.- Type Parameters:
T- The type ofThrowable.- Parameters:
cause- The cause to initialize.clazz- The class where thecauseis thrown from.method- The method where thecauseis thrown from.- Returns:
causeafter the stack trace has been initialized.
-
matches
public static boolean matches(java.lang.Throwable original, java.lang.Class<? extends java.lang.Throwable> toMatch)Finds if the passedoriginalor any of its causes are an instance oftoMatch.- Parameters:
original-Throwableto search.toMatch-Throwableto find inoriginal.- Returns:
trueif passedoriginalor any of its causes are an instance oftoMatch.
-
catchUnexpected
public static java.lang.Throwable catchUnexpected(@Nullable java.lang.Throwable delayedCause, java.lang.Throwable cause)Used in scenarios where multiple operations which aren't expected to throw but exception propagation must be delayed to preserve control flow.- Parameters:
delayedCause- A previously thrownThrowableornullif no previous exception was thrown.cause- The newly thrownThrowable.- Returns:
- The new cause to feed back into this method as
delayedCausethis method or later throw.
-
-