Class Throwables
java.lang.Object
org.junit.internal.Throwables
Miscellaneous functions dealing with
Throwable.- Since:
- 4.12
- Author:
- kcooney@google.com (Kevin Cooney)
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetStacktrace(Throwable exception) Returns the stacktrace of the given Throwable as a String.static StringgetTrimmedStackTrace(Throwable exception) Gets a trimmed version of the stack trace of the given exception.static ExceptionRethrows the givenThrowable, allowing the caller to declare that it throwsException.
-
Method Details
-
rethrowAsException
Rethrows the givenThrowable, allowing the caller to declare that it throwsException. This is useful when your callers have nothing reasonable they can do when aThrowableis thrown. This is declared to returnExceptionso it can be used in athrowclause:try { doSomething(); } catch (Throwable e} { throw Throwables.rethrowAsException(e); } doSomethingLater();- Parameters:
e- exception to rethrow- Returns:
- does not return anything
- Throws:
Exception- Since:
- 4.12
-
getStacktrace
-
getTrimmedStackTrace
-