public final class Throwables
extends java.lang.Object
Throwable.| Modifier and Type | Method and Description |
|---|---|
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.
|
static java.lang.Exception |
rethrowAsException(java.lang.Throwable e)
Rethrows the given
Throwable, allowing the caller to
declare that it throws Exception. |
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.Exceptionpublic static java.lang.String getStacktrace(java.lang.Throwable exception)
public static java.lang.String getTrimmedStackTrace(java.lang.Throwable exception)
Copyright (c) OSGi Alliance (2014, 2020). All Rights Reserved.