public class CassandraExceptionTranslator extends Object implements CqlExceptionTranslator
PersistenceExceptionTranslator for Cassandra.
Convert the given runtime exception to an appropriate exception from the org.springframework.dao hierarchy.
Preserves exception if it's already a DataAccessException and ignores non DriverExceptions returning
null. Falls back to CassandraUncategorizedException in case there's no mapping to a more detailed
exception.
| Constructor and Description |
|---|
CassandraExceptionTranslator() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
buildMessage(String task,
String cql,
RuntimeException ex)
Build a message
String for the given DriverException. |
DataAccessException |
translate(String task,
String cql,
RuntimeException exception)
Translate the given
RuntimeException into a generic DataAccessException. |
DataAccessException |
translateExceptionIfPossible(RuntimeException exception) |
@Nullable public DataAccessException translateExceptionIfPossible(RuntimeException exception)
translateExceptionIfPossible in interface PersistenceExceptionTranslatorpublic DataAccessException translate(@Nullable String task, @Nullable String cql, RuntimeException exception)
CqlExceptionTranslatorRuntimeException into a generic DataAccessException.
The returned DataAccessException is supposed to contain the original DriverException as root cause.
However, client code may not generally rely on this due to DataAccessExceptions possibly being caused by
other resource APIs as well. That said, a getRootCause() instanceof DataAccessException check (and
subsequent cast) is considered reliable when expecting Cassandra-based access to have happened.
translate in interface CqlExceptionTranslatortask - readable text describing the task being attempted.cql - CQL query or update that caused the problem (may be null).exception - the offending DriverException.RuntimeException.NestedRuntimeException.getRootCause()protected String buildMessage(@Nullable String task, @Nullable String cql, RuntimeException ex)
String for the given DriverException.
To be called by translator subclasses when creating an instance of a generic
DataAccessException class.
task - readable text describing the task being attemptedcql - the CQL statement that caused the problem (may be null)ex - the offending DriverExceptionString to useCopyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.