ExceptionUtil { public static void throwRuntimeExceptionOrError(Throwable throwable) { if (throwable instanceof Error) { throw (Error) throwable; } if (throwable instanceof RuntimeException) { throw (RuntimeException) throwable; } throw new RuntimeException(throwable); }  static boolean causedBy(Throwable throwable, Class<? extends Throwable> causeType); static Throwable getRootCause(Throwable throwable); static List<Throwable> getCauses(Throwable throwable); static List<Throwable> getCauses(Throwable throwable, boolean reversed); static RuntimeException toRuntimeException(Exception exception); static RuntimeException toRuntimeException(Exception exception,
            Class<? extends RuntimeException> runtimeExceptionClass); static void throwExceptionOrError(Throwable throwable); static void throwRuntimeExceptionOrError(Throwable throwable); static String getStackTrace(Throwable throwable);  }
@Test public void throwRuntimeExceptionOrError() { try { ExceptionUtil.throwRuntimeExceptionOrError(new Exception("test")); fail(); } catch (RuntimeException e) { assertEquals("test", e.getCause().getMessage()); } try { ExceptionUtil.throwRuntimeExceptionOrError(new RuntimeException("test")); fail(); } catch (RuntimeException e) { assertEquals("test", e.getMessage()); } try { ExceptionUtil.throwRuntimeExceptionOrError(new Error("test")); fail(); } catch (Error e) { assertEquals("test", e.getMessage()); } }