aligned C* exceptions more with Spring exceptions than C* ones
This commit is contained in:
@@ -17,9 +17,39 @@ package org.springframework.data.cassandra.core;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.support.PersistenceExceptionTranslator;
|
||||
import org.springframework.data.cassandra.core.exceptions.*;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraAuthenticationException;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraInternalException;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraInvalidConfigurationInQueryException;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraInvalidQueryException;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraTypeMismatchException;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraKeyspaceExistsException;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraConnectionFailureException;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraReadTimeoutException;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraQuerySyntaxException;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraTableExistsException;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraTraceRetrievalException;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraTruncateException;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraUnauthorizedException;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraInsufficientReplicasAvailableException;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraUncategorizedException;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraWriteTimeoutException;
|
||||
|
||||
import com.datastax.driver.core.exceptions.*;
|
||||
import com.datastax.driver.core.WriteType;
|
||||
import com.datastax.driver.core.exceptions.AlreadyExistsException;
|
||||
import com.datastax.driver.core.exceptions.AuthenticationException;
|
||||
import com.datastax.driver.core.exceptions.DriverException;
|
||||
import com.datastax.driver.core.exceptions.DriverInternalError;
|
||||
import com.datastax.driver.core.exceptions.InvalidConfigurationInQueryException;
|
||||
import com.datastax.driver.core.exceptions.InvalidQueryException;
|
||||
import com.datastax.driver.core.exceptions.InvalidTypeException;
|
||||
import com.datastax.driver.core.exceptions.NoHostAvailableException;
|
||||
import com.datastax.driver.core.exceptions.ReadTimeoutException;
|
||||
import com.datastax.driver.core.exceptions.SyntaxError;
|
||||
import com.datastax.driver.core.exceptions.TraceRetrievalException;
|
||||
import com.datastax.driver.core.exceptions.TruncateException;
|
||||
import com.datastax.driver.core.exceptions.UnauthorizedException;
|
||||
import com.datastax.driver.core.exceptions.UnavailableException;
|
||||
import com.datastax.driver.core.exceptions.WriteTimeoutException;
|
||||
|
||||
/**
|
||||
* Simple {@link PersistenceExceptionTranslator} for Cassandra. Convert the
|
||||
@@ -47,43 +77,60 @@ public class CassandraExceptionTranslator implements
|
||||
return null;
|
||||
}
|
||||
|
||||
// Remember: subclasses must come before superclasses, otherwise the
|
||||
// superclass would match before the subclass!
|
||||
|
||||
if (x instanceof AuthenticationException) {
|
||||
return new CassandraAuthenticationException(x.getMessage(), x);
|
||||
return new CassandraAuthenticationException(
|
||||
((AuthenticationException) x).getHost(), x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof DriverInternalError) {
|
||||
return new CassandraDriverInternalErrorException(x.getMessage(), x);
|
||||
return new CassandraInternalException(x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof InvalidTypeException) {
|
||||
return new CassandraInvalidTypeException(x.getMessage(), x);
|
||||
return new CassandraTypeMismatchException(x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof NoHostAvailableException) {
|
||||
return new CassandraNoHostAvailableException(x.getMessage(), x);
|
||||
return new CassandraConnectionFailureException(
|
||||
((NoHostAvailableException) x).getErrors(), x.getMessage(),
|
||||
x);
|
||||
}
|
||||
if (x instanceof ReadTimeoutException) {
|
||||
return new CassandraReadTimeoutException(x.getMessage(), x);
|
||||
return new CassandraReadTimeoutException(
|
||||
((ReadTimeoutException) x).wasDataRetrieved(),
|
||||
x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof WriteTimeoutException) {
|
||||
return new CassandraWriteTimeoutException(x.getMessage(), x);
|
||||
WriteType writeType = ((WriteTimeoutException) x).getWriteType();
|
||||
return new CassandraWriteTimeoutException(writeType == null ? null
|
||||
: writeType.name(), x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof TruncateException) {
|
||||
return new CassandraTruncateException(x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof UnavailableException) {
|
||||
return new CassandraUnavailableException(x.getMessage(), x);
|
||||
UnavailableException ux = (UnavailableException) x;
|
||||
return new CassandraInsufficientReplicasAvailableException(
|
||||
ux.getRequiredReplicas(), ux.getAliveReplicas(),
|
||||
x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof AlreadyExistsException) {
|
||||
return new CassandraAlreadyExistsException(x.getMessage(), x);
|
||||
AlreadyExistsException aex = (AlreadyExistsException) x;
|
||||
|
||||
return aex.wasTableCreation() ? new CassandraTableExistsException(
|
||||
aex.getTable(), x.getMessage(), x)
|
||||
: new CassandraKeyspaceExistsException(aex.getKeyspace(),
|
||||
x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof InvalidConfigurationInQueryException) {
|
||||
return new CassandraInvalidConfigurationInQueryException(
|
||||
x.getMessage(), x);
|
||||
}
|
||||
// this must come after cases for subclasses
|
||||
if (x instanceof InvalidQueryException) {
|
||||
return new CassandraInvalidQueryException(x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof SyntaxError) {
|
||||
return new CassandraSyntaxErrorException(x.getMessage(), x);
|
||||
return new CassandraQuerySyntaxException(x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof UnauthorizedException) {
|
||||
return new CassandraUnauthorizedException(x.getMessage(), x);
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.dao.support.PersistenceExceptionTranslator;
|
||||
import org.springframework.data.cassandra.convert.CassandraConverter;
|
||||
import org.springframework.data.cassandra.core.exceptions.CassandraConnectionFailureException;
|
||||
import org.springframework.data.cassandra.mapping.CassandraPersistentEntity;
|
||||
import org.springframework.data.cassandra.mapping.CassandraPersistentProperty;
|
||||
import org.springframework.data.cassandra.vo.RingMember;
|
||||
@@ -38,7 +37,6 @@ import com.datastax.driver.core.Metadata;
|
||||
import com.datastax.driver.core.ResultSet;
|
||||
import com.datastax.driver.core.Row;
|
||||
import com.datastax.driver.core.Session;
|
||||
import com.datastax.driver.core.exceptions.NoHostAvailableException;
|
||||
|
||||
/**
|
||||
* @author Alex Shvid
|
||||
@@ -124,8 +122,6 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
public ResultSet executeQuery(String query) {
|
||||
try {
|
||||
return session.execute(query);
|
||||
} catch (NoHostAvailableException e) {
|
||||
throw new CassandraConnectionFailureException("no host available", e);
|
||||
} catch (RuntimeException e) {
|
||||
throw potentiallyConvertRuntimeException(e);
|
||||
}
|
||||
@@ -239,8 +235,6 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
result.add(readRowCallback.doWith(row));
|
||||
}
|
||||
return result;
|
||||
} catch (NoHostAvailableException e) {
|
||||
throw new CassandraConnectionFailureException("no host available", e);
|
||||
} catch (RuntimeException e) {
|
||||
throw potentiallyConvertRuntimeException(e);
|
||||
}
|
||||
@@ -259,8 +253,6 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
} catch (NoHostAvailableException e) {
|
||||
throw new CassandraConnectionFailureException("no host available", e);
|
||||
} catch (RuntimeException e) {
|
||||
throw potentiallyConvertRuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.NonTransientDataAccessException;
|
||||
|
||||
public class CassandraAlreadyExistsException extends
|
||||
NonTransientDataAccessException {
|
||||
|
||||
private static final long serialVersionUID = 6032967419751410352L;
|
||||
|
||||
public CassandraAlreadyExistsException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public CassandraAlreadyExistsException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,44 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
import org.springframework.dao.PermissionDeniedDataAccessException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for a Cassandra authentication failure.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraAuthenticationException extends
|
||||
PermissionDeniedDataAccessException {
|
||||
|
||||
private static final long serialVersionUID = 8556304586797273927L;
|
||||
|
||||
public CassandraAuthenticationException(String msg, Throwable cause) {
|
||||
private InetAddress host;
|
||||
|
||||
public CassandraAuthenticationException(InetAddress host, String msg,
|
||||
Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public InetAddress getHost() {
|
||||
return host;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,25 +13,35 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.dao.DataAccessResourceFailureException;
|
||||
|
||||
/**
|
||||
* Cassandra connection exception.
|
||||
* Spring data access exception for Cassandra when no host is available.
|
||||
*
|
||||
* @author Alex Shvid
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraConnectionFailureException extends DataAccessResourceFailureException {
|
||||
public class CassandraConnectionFailureException extends
|
||||
DataAccessResourceFailureException {
|
||||
|
||||
private static final long serialVersionUID = 4856524591258560460L;
|
||||
private static final long serialVersionUID = 6299912054261646552L;
|
||||
|
||||
public CassandraConnectionFailureException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
private final Map<InetAddress, String> messagesByHost = new HashMap<InetAddress, String>();
|
||||
|
||||
public CassandraConnectionFailureException(String msg, Throwable cause) {
|
||||
public CassandraConnectionFailureException(
|
||||
Map<InetAddress, String> messagesByHost, String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.messagesByHost.putAll(messagesByHost);
|
||||
}
|
||||
|
||||
public Map<InetAddress, String> getMessagesByHost() {
|
||||
return Collections.unmodifiableMap(messagesByHost);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.DataAccessResourceFailureException;
|
||||
|
||||
public class CassandraDriverInternalErrorException extends
|
||||
DataAccessResourceFailureException {
|
||||
|
||||
private static final long serialVersionUID = 433061676465346338L;
|
||||
|
||||
public CassandraDriverInternalErrorException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public CassandraDriverInternalErrorException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.TransientDataAccessException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for Cassandra when insufficient replicas are
|
||||
* available for a given consistency level.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraInsufficientReplicasAvailableException extends
|
||||
TransientDataAccessException {
|
||||
|
||||
private static final long serialVersionUID = 6415130674604814905L;
|
||||
|
||||
private int numberRequired;
|
||||
private int numberAlive;
|
||||
|
||||
public CassandraInsufficientReplicasAvailableException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public CassandraInsufficientReplicasAvailableException(int numberRequired,
|
||||
int numberAlive, String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.numberRequired = numberRequired;
|
||||
this.numberAlive = numberAlive;
|
||||
}
|
||||
|
||||
public int getNumberRequired() {
|
||||
return numberRequired;
|
||||
}
|
||||
|
||||
public int getNumberAlive() {
|
||||
return numberAlive;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for a Cassandra internal error.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraInternalException extends DataAccessException {
|
||||
|
||||
private static final long serialVersionUID = 433061676465346338L;
|
||||
|
||||
public CassandraInternalException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public CassandraInternalException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for a Cassandra query that is syntactically
|
||||
* correct but has an invalid configuration clause.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraInvalidConfigurationInQueryException extends
|
||||
InvalidDataAccessApiUsageException {
|
||||
|
||||
@@ -11,7 +33,8 @@ public class CassandraInvalidConfigurationInQueryException extends
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public CassandraInvalidConfigurationInQueryException(String msg, Throwable cause) {
|
||||
public CassandraInvalidConfigurationInQueryException(String msg,
|
||||
Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for a Cassandra query that's syntactically
|
||||
* correct but invalid.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraInvalidQueryException extends
|
||||
InvalidDataAccessApiUsageException {
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.TypeMismatchDataAccessException;
|
||||
|
||||
public class CassandraInvalidTypeException extends
|
||||
TypeMismatchDataAccessException {
|
||||
|
||||
private static final long serialVersionUID = -7420058975444905629L;
|
||||
|
||||
public CassandraInvalidTypeException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public CassandraInvalidTypeException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
/**
|
||||
* Spring data access exception for Cassandra when a keyspace being created
|
||||
* already exists.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraKeyspaceExistsException extends
|
||||
CassandraSchemaElementExistsException {
|
||||
|
||||
private static final long serialVersionUID = 6032967419751410352L;
|
||||
|
||||
public CassandraKeyspaceExistsException(String keyspaceName, String msg,
|
||||
Throwable cause) {
|
||||
super(keyspaceName, ElementType.KEYSPACE, msg, cause);
|
||||
}
|
||||
|
||||
public String getKeyspaceName() {
|
||||
return getElementName();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.DataAccessResourceFailureException;
|
||||
|
||||
public class CassandraNoHostAvailableException extends
|
||||
DataAccessResourceFailureException {
|
||||
|
||||
private static final long serialVersionUID = 6299912054261646552L;
|
||||
|
||||
public CassandraNoHostAvailableException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public CassandraNoHostAvailableException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for a Cassandra query syntax error.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraQuerySyntaxException extends InvalidDataAccessApiUsageException {
|
||||
|
||||
private static final long serialVersionUID = 4398474399882434154L;
|
||||
|
||||
public CassandraQuerySyntaxException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public CassandraQuerySyntaxException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,41 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.QueryTimeoutException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for a Cassandra read timeout.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraReadTimeoutException extends QueryTimeoutException {
|
||||
|
||||
private static final long serialVersionUID = -787022307935203387L;
|
||||
|
||||
public CassandraReadTimeoutException(String msg) {
|
||||
private boolean wasDataReceived;
|
||||
|
||||
public CassandraReadTimeoutException(boolean wasDataReceived, String msg,
|
||||
Throwable cause) {
|
||||
super(msg);
|
||||
this.wasDataReceived = wasDataReceived;
|
||||
}
|
||||
|
||||
public CassandraReadTimeoutException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
public boolean getWasDataReceived() {
|
||||
return wasDataReceived;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.NonTransientDataAccessException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for when Cassandra schema element being created
|
||||
* already exists.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraSchemaElementExistsException extends
|
||||
NonTransientDataAccessException {
|
||||
|
||||
private static final long serialVersionUID = 7798361273692300162L;
|
||||
|
||||
public enum ElementType {
|
||||
KEYSPACE, TABLE, COLUMN, INDEX;
|
||||
}
|
||||
|
||||
private String elementName;
|
||||
private ElementType elementType;
|
||||
|
||||
public CassandraSchemaElementExistsException(String elementName,
|
||||
ElementType elementType, String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.elementName = elementName;
|
||||
this.elementType = elementType;
|
||||
}
|
||||
|
||||
public String getElementName() {
|
||||
return elementName;
|
||||
}
|
||||
|
||||
public ElementType getElementType() {
|
||||
return elementType;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
|
||||
public class CassandraSyntaxErrorException extends InvalidDataAccessApiUsageException {
|
||||
|
||||
private static final long serialVersionUID = 4398474399882434154L;
|
||||
|
||||
public CassandraSyntaxErrorException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public CassandraSyntaxErrorException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
/**
|
||||
* Spring data access exception for when a Cassandra table being created already
|
||||
* exists.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraTableExistsException extends
|
||||
CassandraSchemaElementExistsException {
|
||||
|
||||
private static final long serialVersionUID = 6032967419751410352L;
|
||||
|
||||
public CassandraTableExistsException(String tableName, String msg,
|
||||
Throwable cause) {
|
||||
super(tableName, ElementType.TABLE, msg, cause);
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return getElementName();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.TransientDataAccessException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for a Cassandra trace retrieval exception.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraTraceRetrievalException extends
|
||||
TransientDataAccessException {
|
||||
|
||||
|
||||
@@ -1,7 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.TransientDataAccessException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for a Cassandra truncate exception.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraTruncateException extends TransientDataAccessException {
|
||||
|
||||
private static final long serialVersionUID = 5730642491362430311L;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.TypeMismatchDataAccessException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for a Cassandra type mismatch exception.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraTypeMismatchException extends
|
||||
TypeMismatchDataAccessException {
|
||||
|
||||
private static final long serialVersionUID = -7420058975444905629L;
|
||||
|
||||
public CassandraTypeMismatchException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public CassandraTypeMismatchException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.PermissionDeniedDataAccessException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for when access to a Cassandra element is
|
||||
* denied.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraUnauthorizedException extends
|
||||
PermissionDeniedDataAccessException {
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
|
||||
public class CassandraUnavailableException extends ConcurrencyFailureException {
|
||||
|
||||
private static final long serialVersionUID = 6415130674604814905L;
|
||||
|
||||
public CassandraUnavailableException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public CassandraUnavailableException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,11 @@ package org.springframework.data.cassandra.core.exceptions;
|
||||
import org.springframework.dao.UncategorizedDataAccessException;
|
||||
|
||||
/**
|
||||
* Exception thrown when we can't classify a Cassandra exception into one of Spring generic data access exceptions.
|
||||
*
|
||||
* Spring data access exception for an uncategorized Cassandra exception.
|
||||
*
|
||||
* @author Alex Shvid
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
|
||||
public class CassandraUncategorizedException extends UncategorizedDataAccessException {
|
||||
|
||||
private static final long serialVersionUID = 1029525121238025444L;
|
||||
|
||||
@@ -1,16 +1,41 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
import org.springframework.dao.QueryTimeoutException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for a Cassandra write timeout.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraWriteTimeoutException extends QueryTimeoutException {
|
||||
|
||||
private static final long serialVersionUID = -4374826375213670718L;
|
||||
|
||||
public CassandraWriteTimeoutException(String msg) {
|
||||
super(msg);
|
||||
private String writeType;
|
||||
|
||||
public CassandraWriteTimeoutException(String writeType, String msg,
|
||||
Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.writeType = writeType;
|
||||
}
|
||||
|
||||
public CassandraWriteTimeoutException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
public String getWriteType() {
|
||||
return writeType;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user