@Test public void testWrappedRuntimeExceptionIsSame() { RuntimeException exception = new RuntimeException(); RuntimeException expectedException = new RuntimeException(exception); RuntimeException actualCause = Exceptions.tryGetCassandraExceptionCause(expectedException); assertThat(actualCause).isSameAs(expectedException); assertThat(actualCause.getSuppressed()).isEmpty(); assertThat(exception.getSuppressed()).isEmpty(); }
public static RuntimeException tryGetCassandraExceptionCause(RuntimeException exception) { Throwable cause = exception.getCause(); if (cause instanceof CassandraException) { cause.addSuppressed(exception); return (CassandraException) cause; } else if (cause instanceof RuntimeException) { RuntimeException causeOfCause = tryGetCassandraExceptionCause((RuntimeException) cause); if (causeOfCause == cause) { return exception; } causeOfCause.addSuppressed(exception); return causeOfCause; } else { return exception; } }
Exceptions { public static RuntimeException tryGetCassandraExceptionCause(RuntimeException exception) { Throwable cause = exception.getCause(); if (cause instanceof CassandraException) { cause.addSuppressed(exception); return (CassandraException) cause; } else if (cause instanceof RuntimeException) { RuntimeException causeOfCause = tryGetCassandraExceptionCause((RuntimeException) cause); if (causeOfCause == cause) { return exception; } causeOfCause.addSuppressed(exception); return causeOfCause; } else { return exception; } } }
Exceptions { public static RuntimeException tryGetCassandraExceptionCause(RuntimeException exception) { Throwable cause = exception.getCause(); if (cause instanceof CassandraException) { cause.addSuppressed(exception); return (CassandraException) cause; } else if (cause instanceof RuntimeException) { RuntimeException causeOfCause = tryGetCassandraExceptionCause((RuntimeException) cause); if (causeOfCause == cause) { return exception; } causeOfCause.addSuppressed(exception); return causeOfCause; } else { return exception; } } private  Exceptions(); }
Exceptions { public static RuntimeException tryGetCassandraExceptionCause(RuntimeException exception) { Throwable cause = exception.getCause(); if (cause instanceof CassandraException) { cause.addSuppressed(exception); return (CassandraException) cause; } else if (cause instanceof RuntimeException) { RuntimeException causeOfCause = tryGetCassandraExceptionCause((RuntimeException) cause); if (causeOfCause == cause) { return exception; } causeOfCause.addSuppressed(exception); return causeOfCause; } else { return exception; } } private  Exceptions(); static RuntimeException tryGetCassandraExceptionCause(RuntimeException exception); static T appendCause(T exception, Throwable cause); }
Exceptions { public static RuntimeException tryGetCassandraExceptionCause(RuntimeException exception) { Throwable cause = exception.getCause(); if (cause instanceof CassandraException) { cause.addSuppressed(exception); return (CassandraException) cause; } else if (cause instanceof RuntimeException) { RuntimeException causeOfCause = tryGetCassandraExceptionCause((RuntimeException) cause); if (causeOfCause == cause) { return exception; } causeOfCause.addSuppressed(exception); return causeOfCause; } else { return exception; } } private  Exceptions(); static RuntimeException tryGetCassandraExceptionCause(RuntimeException exception); static T appendCause(T exception, Throwable cause);  }