public final class ExceptionHelper extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ExceptionHelper.Handler<T extends Throwable>
Exception handler.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
concatenateMessages(Throwable headOfChain)
Concatenates the messages of an exception chain.
|
static Throwable |
extractException(boolean first,
Throwable headOfChain,
Class<? extends Throwable>... types)
Extracts any of the given exception types from an exception chain.
|
static <T extends Throwable> |
extractException(Class<T> type,
boolean first,
Throwable headOfChain)
Extracts the given exception type from an exception chain.
|
static String |
getStackTraceAsString(Throwable cause)
Returns the stacktrace of a given exception as a string.
|
static boolean |
handleException(boolean first,
Throwable headOfChain,
ExceptionHelper.Handler<? extends Throwable>... handlers)
Extracts any of the given exception types from an exception chain.
|
public static <T extends Throwable> T extractException(Class<T> type, boolean first, Throwable headOfChain)
T - the exception type to search fortype - the exception class to search forfirst - true if finds the first, else the last in chainheadOfChain - the head of chained exceptions, may be nullpublic static Throwable extractException(boolean first, Throwable headOfChain, Class<? extends Throwable>... types)
first - true if finds the first, else the last in chainheadOfChain - the head of chained exceptions, may be nulltypes - the exception classes to search forpublic static boolean handleException(boolean first,
Throwable headOfChain,
ExceptionHelper.Handler<? extends Throwable>... handlers)
first - true if handle the first, else the last in chainheadOfChain - the head of chained exceptions, may be nullhandlers - the exception handlerspublic static String concatenateMessages(Throwable headOfChain)
headOfChain - the head of chained exceptions, may be nullTentackle - distributed, domain- and model-driven