public class ThrowableUtil extends Object
| Constructor and Description |
|---|
ThrowableUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
contains(Throwable t,
Class<? extends Throwable> e)
Whether the specified type exception is included in the exception stack.
|
static <T extends Throwable> |
firstCause(Throwable t,
Class<T> e)
from bottom to top (old to new) of the stack, find the first (newest) specified type exception
|
static <T extends Throwable> |
lastCause(Throwable t,
Class<T> e)
from bottom to top of the stack (old to new), find the last (oldest) specified type exception
|
static void |
print(Appendable buffer,
Throwable t)
print StackTrace to buffer in 5-StackTrace (except root cause), Reversed, Shorten.
|
static void |
print(Appendable buffer,
Throwable t,
boolean reverse,
boolean shorten)
print StackTrace to buffer.
|
static void |
print(Appendable buffer,
Throwable t,
boolean reverse,
boolean shorten,
int maxStack,
int maxCause)
print StackTrace to buffer.
|
static Throwable |
root(Throwable t)
get the root StackTrace which is the root cause.
|
static @NotNull String |
rootString(Throwable t)
print root StackTrace to String
|
static void |
throwCause(Throwable t,
Class<? extends RuntimeException>... runtime) |
static void |
throwMatch(Throwable t,
Class<? extends RuntimeException>... runtime) |
static @NotNull String |
toString(Throwable t)
print StackTrace to String
|
public static void print(@Param.Out Appendable buffer, Throwable t)
buffer - to writet - throwablepublic static void print(@Param.Out Appendable buffer, Throwable t, boolean reverse, boolean shorten)
buffer - to writet - throwablereverse - reverse the stackshorten - shorten the classpublic static void print(@Param.Out Appendable buffer, Throwable t, boolean reverse, boolean shorten, int maxStack, int maxCause)
buffer - to writet - throwablereverse - reverse the stackshorten - shorten the classmaxStack - max Stack (except root cause) to print, default Integer#MAX_VALUEmaxCause - max Cause to print, default Integer#MAX_VALUE@NotNull public static @NotNull String rootString(Throwable t)
@Contract(value="!null->!null") public static Throwable root(Throwable t)
public static boolean contains(Throwable t, Class<? extends Throwable> e)
t - the exception stacke - the specified typepublic static <T extends Throwable> T firstCause(Throwable t, Class<T> e)
T - Typet - the exception stacke - the specified typepublic static <T extends Throwable> T lastCause(Throwable t, Class<T> e)
T - Typet - the exception stacke - the specified type@SafeVarargs public static void throwMatch(Throwable t, Class<? extends RuntimeException>... runtime)
@SafeVarargs public static void throwCause(Throwable t, Class<? extends RuntimeException>... runtime)
Copyright © 2023. All rights reserved.