Package org.junit.internal
Class Throwables
- java.lang.Object
-
- org.junit.internal.Throwables
-
public final class Throwables extends java.lang.ObjectMiscellaneous functions dealing withThrowable.- Since:
- 4.12
-
-
Constructor Summary
Constructors Modifier Constructor Description privateThrowables()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static <T extends java.lang.Throwable>
voidrethrow(java.lang.Throwable e)static java.lang.ExceptionrethrowAsException(java.lang.Throwable e)Rethrows the givenThrowable, allowing the caller to declare that it throwsException.
-
-
-
Method Detail
-
rethrowAsException
public static java.lang.Exception rethrowAsException(java.lang.Throwable e) throws java.lang.ExceptionRethrows 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:
java.lang.Exception- Since:
- 4.12
-
rethrow
private static <T extends java.lang.Throwable> void rethrow(java.lang.Throwable e) throws T extends java.lang.Throwable- Throws:
T extends java.lang.Throwable
-
-