Class ThrowableUtils
- java.lang.Object
-
- io.servicetalk.concurrent.internal.ThrowableUtils
-
public final class ThrowableUtils extends java.lang.Object
Utility for creating staticThrowable
s.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Throwable
catchUnexpected(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 boolean
matches(java.lang.Throwable original, java.lang.Class<? extends java.lang.Throwable> toMatch)
Finds if the passedoriginal
or 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 theStackTraceElement
for the givenThrowable
, using theClass
and 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 theStackTraceElement
for the givenThrowable
, using theClass
and method name.- Type Parameters:
T
- The type ofThrowable
.- Parameters:
cause
- The cause to initialize.clazz
- The class where thecause
is thrown from.method
- The method where thecause
is thrown from.- Returns:
cause
after 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 passedoriginal
or any of its causes are an instance oftoMatch
.- Parameters:
original
-Throwable
to search.toMatch
-Throwable
to find inoriginal
.- Returns:
true
if passedoriginal
or 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 thrownThrowable
ornull
if no previous exception was thrown.cause
- The newly thrownThrowable
.- Returns:
- The new cause to feed back into this method as
delayedCause
this method or later throw.
-
-