public final class Throwables extends Object
Throwable.| Modifier and Type | Method and Description |
|---|---|
static String |
getStacktrace(Throwable exception)
Returns the stacktrace of the given Throwable as a String.
|
static String |
getTrimmedStackTrace(Throwable exception)
Gets a trimmed version of the stack trace of the given exception.
|
static Exception |
rethrowAsException(Throwable e)
Rethrows the given
Throwable, allowing the caller to
declare that it throws Exception. |
public static Exception rethrowAsException(Throwable e) throws 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 rethrowExceptionpublic static String getStacktrace(Throwable exception)
public static String getTrimmedStackTrace(Throwable exception)
Copyright © 2002–2025 JUnit. All rights reserved.