/** * Translate the given {@link DriverException} into a generic {@link DataAccessException}. * <p> * The returned {@link DataAccessException} is supposed to contain the original {@code DriverException} as root cause. * However, client code may not generally rely on this due to {@link DataAccessException}s possibly being caused by * other resource APIs as well. That said, a {@code getRootCause() instanceof DataAccessException} check (and * subsequent cast) is considered reliable when expecting Cassandra-based access to have happened. * * @param task readable text describing the task being attempted * @param cql CQL query or update that caused the problem (may be {@literal null}) * @param ex the offending {@link DriverException} * @return the DataAccessException, wrapping the {@code DriverException} * @see org.springframework.dao.DataAccessException#getRootCause() * @see <a href= * "http://docs.spring.io/spring/docs/current/spring-framework-reference/data-access.html#dao-exceptions">Consistent * exception hierarchy</a> */ protected DataAccessException translate(String task, @Nullable String cql, DriverException ex) { Assert.notNull(ex, "DriverException must not be null"); return getExceptionTranslator().translate(task, cql, ex); }
/** * Translate the given {@link DriverException} into a generic {@link DataAccessException}. * <p> * The returned {@link DataAccessException} is supposed to contain the original {@code DriverException} as root cause. * However, client code may not generally rely on this due to {@link DataAccessException}s possibly being caused by * other resource APIs as well. That said, a {@code getRootCause() instanceof DataAccessException} check (and * subsequent cast) is considered reliable when expecting Cassandra-based access to have happened. * * @param ex the offending {@link DriverException} * @return the DataAccessException, wrapping the {@code DriverException} * @see <a href= * "http://docs.spring.io/spring/docs/current/spring-framework-reference/data-access.html#dao-exceptions">Consistent * exception hierarchy</a> * @see DataAccessException */ @Nullable protected DataAccessException translateExceptionIfPossible(DriverException ex) { Assert.notNull(ex, "DriverException must not be null"); return getExceptionTranslator().translateExceptionIfPossible(ex); }
@Override public ListenableFuture<ResultSet> doInSession(Session session) throws DriverException, DataAccessException { return new GuavaListenableFutureAdapter<>(session.executeAsync(statement), e -> (e instanceof DriverException ? exceptionTranslator.translate("AsyncStatementCallback", getCql(), (DriverException) e) : exceptionTranslator.translateExceptionIfPossible(e))); }
/** * Translate the given {@link DriverException} into a generic {@link DataAccessException}. * <p> * The returned {@link DataAccessException} is supposed to contain the original {@code DriverException} as root cause. * However, client code may not generally rely on this due to {@link DataAccessException}s possibly being caused by * other resource APIs as well. That said, a {@code getRootCause() instanceof DataAccessException} check (and * subsequent cast) is considered reliable when expecting Cassandra-based access to have happened. * * @param task readable text describing the task being attempted. * @param cql CQL query or update that caused the problem (may be {@literal null}). * @param ex the offending {@link DriverException}. * @return the DataAccessException, wrapping the {@link DriverException}. * @see org.springframework.dao.DataAccessException#getRootCause() */ default DataAccessException translate(@Nullable String task, @Nullable String cql, DriverException ex) { DataAccessException translated = translateExceptionIfPossible(ex); return translated == null ? new UnsupportedCassandraOperationException("Cannot translate exception", ex) : translated; } }
/** * Translate the given {@link DriverException} into a generic {@link DataAccessException}. * <p> * The returned {@link DataAccessException} is supposed to contain the original {@code DriverException} as root cause. * However, client code may not generally rely on this due to {@link DataAccessException}s possibly being caused by * other resource APIs as well. That said, a {@code getRootCause() instanceof DataAccessException} check (and * subsequent cast) is considered reliable when expecting Cassandra-based access to have happened. * * @param task readable text describing the task being attempted * @param cql CQL query or update that caused the problem (may be {@literal null}) * @param ex the offending {@link DriverException} * @return the DataAccessException, wrapping the {@code DriverException} * @see org.springframework.dao.DataAccessException#getRootCause() * @see <a href= * "http://docs.spring.io/spring/docs/current/spring-framework-reference/data-access.html#dao-exceptions">Consistent * exception hierarchy</a> */ protected DataAccessException translate(String task, @Nullable String cql, DriverException ex) { Assert.notNull(ex, "DriverException must not be null"); return getExceptionTranslator().translate(task, cql, ex); } }
/** * Translate the given {@link DriverException} into a generic {@link DataAccessException}. * <p> * The returned {@link DataAccessException} is supposed to contain the original {@code DriverException} as root cause. * However, client code may not generally rely on this due to {@link DataAccessException}s possibly being caused by * other resource APIs as well. That said, a {@code getRootCause() instanceof DataAccessException} check (and * subsequent cast) is considered reliable when expecting Cassandra-based access to have happened. * * @param ex the offending {@link DriverException} * @return the DataAccessException, wrapping the {@code DriverException} * @see <a href= * "http://docs.spring.io/spring/docs/current/spring-framework-reference/data-access.html#dao-exceptions">Consistent * exception hierarchy</a> * @see DataAccessException */ @Nullable protected DataAccessException translateExceptionIfPossible(DriverException ex) { Assert.notNull(ex, "DriverException must not be null"); return getExceptionTranslator().translateExceptionIfPossible(ex); }