Package io.hekate.core.internal.util
Class ErrorUtils
- java.lang.Object
-
- io.hekate.core.internal.util.ErrorUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Throwable>
TfindCause(Class<T> type, Throwable error)
Returns an error instance of the specified type by scanning thecause
tree.static boolean
isCausedBy(Class<? extends Throwable> type, Throwable error)
Returnstrue
if the specified exceptionis
an error of the specified type or is caused by an error of the specified type.static String
stackTrace(Throwable error)
Returnsstackt race
as string.
-
-
-
Method Detail
-
stackTrace
public static String stackTrace(Throwable error)
Returnsstackt race
as string.- Parameters:
error
- Error.- Returns:
- Stack trace as a string.
-
isCausedBy
public static boolean isCausedBy(Class<? extends Throwable> type, Throwable error)
Returnstrue
if the specified exceptionis
an error of the specified type or is caused by an error of the specified type.This method recursively scans the whole
cause
tree unless an error the specified type is found the bottom of the tree is reached.- Parameters:
type
- Error type to check for.error
- Error (can benull
).- Returns:
true
if the specified exceptionis
an error of the specified type or is caused by an error of the specified type.
-
findCause
public static <T extends Throwable> T findCause(Class<T> type, Throwable error)
Returns an error instance of the specified type by scanning thecause
tree.- Type Parameters:
T
- Error type to search for.- Parameters:
type
- Error type to search for.error
- Error (can benull
).- Returns:
- Error or
null
if the specified error is not of the specified type and is notcaused
by an error of the specified type.
-
-