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 DriverException
s 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
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
buildMessage
(String task, String cql, RuntimeException ex) Build a messageString
for the givenDriverException
.translate
(String task, String cql, RuntimeException exception) Translate the givenRuntimeException
into a genericDataAccessException
.translateExceptionIfPossible
(RuntimeException exception)
-
Constructor Details
-
CassandraExceptionTranslator
public CassandraExceptionTranslator()
-
-
Method Details
-
translateExceptionIfPossible
- Specified by:
translateExceptionIfPossible
in interfacePersistenceExceptionTranslator
-
translate
public DataAccessException translate(@Nullable String task, @Nullable String cql, RuntimeException exception) Description copied from interface:CqlExceptionTranslator
Translate the givenRuntimeException
into a genericDataAccessException
.The returned
DataAccessException
is supposed to contain the originalDriverException
as root cause. However, client code may not generally rely on this due toDataAccessException
s possibly being caused by other resource APIs as well. That said, agetRootCause() instanceof DataAccessException
check (and subsequent cast) is considered reliable when expecting Cassandra-based access to have happened.- Specified by:
translate
in 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 messageString
for the givenDriverException
.To be called by translator subclasses when creating an instance of a generic
DataAccessException
class.- 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
String
to use
-