public final class Throwables
extends java.lang.Object
Throwable
.Modifier and Type | Class and Description |
---|---|
private static class |
Throwables.State |
Modifier and Type | Field and Description |
---|---|
private static java.lang.reflect.Method |
getSuppressed |
private static java.lang.String[] |
REFLECTION_METHOD_NAME_PREFIXES |
private static java.lang.String[] |
TEST_FRAMEWORK_METHOD_NAME_PREFIXES |
private static java.lang.String[] |
TEST_FRAMEWORK_TEST_METHOD_NAME_PREFIXES |
Modifier | Constructor and Description |
---|---|
private |
Throwables() |
Modifier and Type | Method and Description |
---|---|
private static void |
appendStackTraceLines(java.util.List<java.lang.String> stackTraceLines,
java.lang.StringBuilder destBuilder) |
private static <T> java.util.List<T> |
asReversedList(java.util.List<T> list) |
private static java.util.List<java.lang.String> |
getCauseStackTraceLines(java.lang.Throwable exception) |
private static java.lang.String |
getFullStackTrace(java.lang.Throwable exception) |
static java.lang.String |
getStacktrace(java.lang.Throwable exception)
Returns the stacktrace of the given Throwable as a String.
|
static java.lang.String |
getTrimmedStackTrace(java.lang.Throwable exception)
Gets a trimmed version of the stack trace of the given exception.
|
private static java.util.List<java.lang.String> |
getTrimmedStackTraceLines(java.lang.Throwable exception) |
private static boolean |
hasSuppressed(java.lang.Throwable exception) |
private static java.lang.reflect.Method |
initGetSuppressed() |
private static boolean |
isMatchingMethod(java.lang.String methodName,
java.lang.String[] methodNamePrefixes) |
private static boolean |
isReflectionMethod(java.lang.String methodName) |
private static boolean |
isTestFrameworkMethod(java.lang.String methodName) |
private static <T extends java.lang.Throwable> |
rethrow(java.lang.Throwable e) |
static java.lang.Exception |
rethrowAsException(java.lang.Throwable e)
Rethrows the given
Throwable , allowing the caller to
declare that it throws Exception . |
private static final java.lang.reflect.Method getSuppressed
private static final java.lang.String[] TEST_FRAMEWORK_METHOD_NAME_PREFIXES
private static final java.lang.String[] TEST_FRAMEWORK_TEST_METHOD_NAME_PREFIXES
private static final java.lang.String[] REFLECTION_METHOD_NAME_PREFIXES
public static java.lang.Exception rethrowAsException(java.lang.Throwable e) throws java.lang.Exception
Throwable
, allowing the caller to
declare that it throws Exception
. This is useful when
your callers have nothing reasonable they can do when a
Throwable
is thrown. This is declared to return Exception
so it can be used in a throw
clause:
try { doSomething(); } catch (Throwable e} { throw Throwables.rethrowAsException(e); } doSomethingLater();
e
- exception to rethrowjava.lang.Exception
private static <T extends java.lang.Throwable> void rethrow(java.lang.Throwable e) throws T extends java.lang.Throwable
T extends java.lang.Throwable
public static java.lang.String getStacktrace(java.lang.Throwable exception)
public static java.lang.String getTrimmedStackTrace(java.lang.Throwable exception)
private static java.util.List<java.lang.String> getTrimmedStackTraceLines(java.lang.Throwable exception)
private static java.lang.reflect.Method initGetSuppressed()
private static boolean hasSuppressed(java.lang.Throwable exception)
private static java.util.List<java.lang.String> getCauseStackTraceLines(java.lang.Throwable exception)
private static java.lang.String getFullStackTrace(java.lang.Throwable exception)
private static void appendStackTraceLines(java.util.List<java.lang.String> stackTraceLines, java.lang.StringBuilder destBuilder)
private static <T> java.util.List<T> asReversedList(java.util.List<T> list)
private static boolean isTestFrameworkMethod(java.lang.String methodName)
private static boolean isReflectionMethod(java.lang.String methodName)
private static boolean isMatchingMethod(java.lang.String methodName, java.lang.String[] methodNamePrefixes)