public final class ExceptionUtils extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
fatalJvmError(Throwable error)
Checks whether the error has been raised due to a Java
Error . |
static boolean |
hasAnyCause(Throwable error,
Predicate<Throwable> causePredicate)
Predicate that returns
true if any cause in the exception stack
matches the cause predicate. |
static String |
toString(Throwable e)
Generate a String based on the exception.
|
static String |
toString(Throwable e,
String indentation)
Generate a String based on the exception.
|
public static boolean hasAnyCause(Throwable error, Predicate<Throwable> causePredicate)
true
if any cause in the exception stack
matches the cause predicate.
If a cause matches the predicate, then it return true
immediately
(skipping other checks).
error
- the root error to analyzecausePredicate
- the predicate to apply to causes recursivelypublic static boolean fatalJvmError(Throwable error)
Error
.
Error
s should not be ignored. For example, if there is a
OutOfMemoryError
, retrying may result in consuming more memory
and totally crash the JVM or hang the system.error
- the raised errorpublic static String toString(Throwable e)
Throwable.toString()
method, the Throwable.getCause()
may
also be included in the generated string (depending of logging
configuration). If logger associated to this class is configured to
DEBUG
or TRACE
, then the cause is included.e
- the error to convert to a stringpublic static String toString(Throwable e, String indentation)
Throwable.toString()
method, the Throwable.getCause()
may
also be included in the generated string (depending of logging
configuration). If logger associated to this class is configured to
DEBUG
or TRACE
, then the cause is included.e
- the error to convert to a stringindentation
- the initial indentationCopyright © 2021. All rights reserved.