Exceptions { public static void propagateIfFatal(Throwable throwable) { propagateIfInterrupt(throwable); if (throwable instanceof Error) { throw (Error) throwable; } }  static boolean isPrefixBoring(Throwable t); static RuntimeException propagate(Throwable throwable); @Deprecated static RuntimeException propagate(String msg, Throwable throwable); static RuntimeException propagateAnnotateIfWrapping(String msg, Throwable throwable); static RuntimeException propagateAnnotated(String msg, Throwable throwable); static void propagateIfInterrupt(Throwable throwable); static void propagateIfFatal(Throwable throwable); static boolean isFatal(Throwable throwable); static Predicate<Throwable> isFatalPredicate(); @SuppressWarnings("unchecked") static T getFirstThrowableOfType(Throwable from, Class<T> clazz); static Throwable getFirstThrowableMatching(Throwable from, Predicate<? super Throwable> filter); static Throwable getFirstInteresting(Throwable throwable); static Throwable collapse(Throwable source); static Throwable collapseIncludingAllCausalMessages(Throwable source); static Throwable collapse(Throwable source, boolean collapseCausalChain); static List<Throwable> getCausalChain(Throwable t); static boolean isSkippableInContext(Throwable e, Object... contexts); static String collapseText(Throwable t); static String collapseTextInContext(Throwable t, Object ...contexts); static String collapseTextIncludingAllCausalMessages(Throwable t); static RuntimeException propagate(Iterable<? extends Throwable> exceptions); static RuntimeException propagate(String prefix, Iterable<? extends Throwable> exceptions); static Throwable create(Iterable<? extends Throwable> exceptions); static RuntimeException create(@Nullable String prefix, Iterable<? extends Throwable> exceptions); @Beta static boolean isPrefixRequiredForMessageToMakeSense(Throwable t); static String getMessageWithAppropriatePrefix(Throwable t); static boolean isRootBoringClassNotFound(Exception e, String clazz); static final int MAX_COLLAPSE_RECURSIVE_DEPTH; }
@Test public void testPropagateIfFatalPropagatesInterruptedException() throws Exception { InterruptedException tothrow = new InterruptedException("simulated"); try { Exceptions.propagateIfFatal(tothrow); fail(); } catch (RuntimeException e) { assertTrue(Thread.interrupted()); assertEquals(e.getCause(), tothrow); } }
@Test public void testPropagateIfFatalPropagatesRuntimeInterruptedException() throws Exception { RuntimeInterruptedException tothrow = new RuntimeInterruptedException(new InterruptedException("simulated")); try { Exceptions.propagateIfFatal(tothrow); fail(); } catch (RuntimeInterruptedException e) { assertTrue(Thread.interrupted()); assertEquals(e, tothrow); } }
@Test public void testPropagateIfFatalPropagatesError() throws Exception { Error tothrow = new Error(); try { Exceptions.propagateIfFatal(tothrow); fail(); } catch (Error e) { assertEquals(e, tothrow); } }
@Test public void testPropagateIfFatalDoesNotPropagatesNormalException() throws Exception { Exception e = new Exception(); Exceptions.propagateIfFatal(e); RuntimeException re = new RuntimeException(); Exceptions.propagateIfFatal(re); Throwable t = new Throwable(); Exceptions.propagateIfFatal(t); }