List of usage examples for org.springframework.dao QueryTimeoutException QueryTimeoutException
public QueryTimeoutException(String msg, Throwable cause)
From source file:jp.classmethod.aws.dynamodb.DynamoDbRepository.java
/** * Translates low level database exceptions to application level exceptions * * @param e the low level amazon client exception * @param action crud action name// ww w.j a v a2 s .c om * @param conditionalSupplier creates condition failed exception (context dependent) * @return a translation of the AWS/DynamoDB exception */ DataAccessException convertDynamoDBException(AmazonClientException e, String action, Supplier<? extends DataAccessException> conditionalSupplier) { final String format = "unable to %s entity due to %s."; if (e instanceof ConditionalCheckFailedException) { return conditionalSupplier.get(); } else if (e instanceof ProvisionedThroughputExceededException) { return new QueryTimeoutException(String.format(Locale.ENGLISH, format, action, "throttling"), e); } else if (e instanceof ResourceNotFoundException) { return new NonTransientDataAccessResourceException( String.format(Locale.ENGLISH, format, action, "table does not exist"), e); } else if (e instanceof AmazonServiceException) { AmazonServiceException ase = (AmazonServiceException) e; if (VALIDATION_EXCEPTION.equals(((AmazonServiceException) e).getErrorCode())) { return new InvalidDataAccessResourceUsageException( String.format(Locale.ENGLISH, format, action, "client error"), e); } else { return new DynamoDbServiceException( String.format(Locale.ENGLISH, format, action, "DynamoDB service error"), ase); } } else { return new InvalidDataAccessResourceUsageException( String.format(Locale.ENGLISH, format, action, "client error"), e); } }
From source file:jp.classmethod.aws.dynamodb.DynamoDbRepository.java
protected DataAccessException processUpdateItemException(K key, AmazonClientException e) { final String format = "unable to update entity due to %s."; if (e instanceof ConditionalCheckFailedException) { if (null == findOne(key)) { return getNotFoundException(UPDATE_FAILED_ENTITY_NOT_FOUND, e); }/*from www . ja v a 2 s .c o m*/ return new OptimisticLockingFailureException(UPDATE_FAILED_NOT_FOUND_OR_BAD_VERSION, e); } else if (e instanceof ProvisionedThroughputExceededException) { throw new QueryTimeoutException(String.format(Locale.ENGLISH, format, "throttling"), e); } else if (e instanceof AmazonServiceException) { AmazonServiceException ase = (AmazonServiceException) e; if (VALIDATION_EXCEPTION.equals(ase.getErrorCode())) { if (EXPRESSION_REFERS_TO_NON_EXTANT_ATTRIBUTE.equals(ase.getErrorMessage()) && null == findOne(key)) { // if no locking and we get a specific message, then it also means the item does not exist return getNotFoundException(UPDATE_FAILED_ENTITY_NOT_FOUND, e); } return new InvalidDataAccessResourceUsageException( String.format(Locale.ENGLISH, format, "client error"), e); } else { return new DynamoDbServiceException(String.format(Locale.ENGLISH, format, "DynamoDB service error"), ase); } } else { return new InvalidDataAccessResourceUsageException( String.format(Locale.ENGLISH, format, "client error"), e); } }