Class CassandraExceptionTranslator
- All Implemented Interfaces:
PersistenceExceptionTranslator,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.
- Author:
- Alex Shvid, Matthew T. Adams, Mark Paluch, Mikhail Polivakha
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringbuildMessage(String task, String cql, RuntimeException ex) Build a messageStringfor the givenDriverException.translate(String task, String cql, RuntimeException exception) Translate the givenRuntimeExceptioninto a genericDataAccessException.translateExceptionIfPossible(RuntimeException exception)
-
Constructor Details
-
CassandraExceptionTranslator
public CassandraExceptionTranslator()
-
-
Method Details
-
translateExceptionIfPossible
- Specified by:
translateExceptionIfPossiblein interfacePersistenceExceptionTranslator
-
translate
public DataAccessException translate(@Nullable String task, @Nullable String cql, RuntimeException exception) Description copied from interface:CqlExceptionTranslatorTranslate the givenRuntimeExceptioninto a genericDataAccessException.The returned
DataAccessExceptionis supposed to contain the originalDriverExceptionas root cause. However, client code may not generally rely on this due toDataAccessExceptions possibly being caused by other resource APIs as well. That said, agetRootCause() instanceof DataAccessExceptioncheck (and subsequent cast) is considered reliable when expecting Cassandra-based access to have happened.- Specified by:
translatein interfaceCqlExceptionTranslator- Parameters:
task- readable text describing the task being attempted.cql- CQL query or update that caused the problem (may be null).exception- the offendingDriverException.- Returns:
- the DataAccessException, wrapping the
RuntimeException. - See Also:
-
buildMessage
Build a messageStringfor the givenDriverException.To be called by translator subclasses when creating an instance of a generic
DataAccessExceptionclass.- Parameters:
task- readable text describing the task being attemptedcql- the CQL statement that caused the problem (may be null)ex- the offendingDriverException- Returns:
- the message
Stringto use
-