com.amazonaws.AmazonServiceException.ErrorType Java Examples

The following examples show how to use com.amazonaws.AmazonServiceException.ErrorType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractDynamoDBTest.java    From nifi with Apache License 2.0 5 votes vote down vote up
protected AmazonServiceException getSampleAwsServiceException() {
    final AmazonServiceException testServiceException = new AmazonServiceException("Test AWS Service Exception");
    testServiceException.setErrorCode("8673509");
    testServiceException.setErrorMessage("This request cannot be serviced right now.");
    testServiceException.setErrorType(ErrorType.Service);
    testServiceException.setServiceName("Dynamo DB");
    testServiceException.setRequestId("TestRequestId-1234567890");

    return testServiceException;
}
 
Example #2
Source File: AmazonS3StubTest.java    From aws-java-sdk-stubs with Apache License 2.0 5 votes vote down vote up
@Test
public void getObjectWithInvalidKey() {
  s3.createBucket("b");
  try {
    s3.getObject("b", "a");
  } catch (final AmazonServiceException e) {
    assertThat(e.getStatusCode(), is(404));
    assertThat(e.getErrorCode(), is("NoSuchKey"));
    assertThat(e.getErrorType(), is(ErrorType.Client));
  }
}
 
Example #3
Source File: AbstractDynamoDBTest.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
protected AmazonServiceException getSampleAwsServiceException() {
    final AmazonServiceException testServiceException = new AmazonServiceException("Test AWS Service Exception");
    testServiceException.setErrorCode("8673509");
    testServiceException.setErrorMessage("This request cannot be serviced right now.");
    testServiceException.setErrorType(ErrorType.Service);
    testServiceException.setServiceName("Dynamo DB");
    testServiceException.setRequestId("TestRequestId-1234567890");

    return testServiceException;
}
 
Example #4
Source File: AwsSmtpRelay.java    From aws-smtp-relay with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void deliver(String from, String to, InputStream inputStream) throws IOException {
    AmazonSimpleEmailService client;
    if (cmd.hasOption("r")) {
        client = AmazonSimpleEmailServiceClientBuilder.standard().withRegion(cmd.getOptionValue("r")).build();
    } else {
        client = AmazonSimpleEmailServiceClientBuilder.standard().build();
    }
    byte[] msg = IOUtils.toByteArray(inputStream);
    RawMessage rawMessage =
            new RawMessage(ByteBuffer.wrap(msg));
    SendRawEmailRequest rawEmailRequest =
            new SendRawEmailRequest(rawMessage).withSource(from)
                                               .withDestinations(to);
    if (cmd.hasOption("a")) {
        rawEmailRequest = rawEmailRequest.withSourceArn(cmd.getOptionValue("a"));
    }
    if (cmd.hasOption("f")) {
        rawEmailRequest = rawEmailRequest.withFromArn(cmd.getOptionValue("f"));
    }
    if (cmd.hasOption("t")) {
        rawEmailRequest = rawEmailRequest.withReturnPathArn(cmd.getOptionValue("t"));
    }
    if (cmd.hasOption("c")) {
        rawEmailRequest = rawEmailRequest.withConfigurationSetName(cmd.getOptionValue("c"));
    }
    try {
        client.sendRawEmail(rawEmailRequest);
    } catch (AmazonSimpleEmailServiceException e) {
        if(e.getErrorType() == ErrorType.Client) {
            // If it's a client error, return a permanent error
            throw new RejectException(e.getMessage());
        } else {
            throw new RejectException(451, e.getMessage());
        }
    }
}
 
Example #5
Source File: AmazonS3StubTest.java    From aws-java-sdk-stubs with Apache License 2.0 5 votes vote down vote up
@Test
public void getObjectWithInvalidBucket() {
  try {
    s3.getObject("b", "a");
  } catch (final AmazonServiceException e) {
    assertThat(e.getStatusCode(), is(404));
    assertThat(e.getErrorCode(), is("NoSuchBucket"));
    assertThat(e.getErrorType(), is(ErrorType.Client));
  }
}
 
Example #6
Source File: AmazonS3StubTest.java    From aws-java-sdk-stubs with Apache License 2.0 5 votes vote down vote up
@Test
public void listObjectsFailsIfNoBucket() {
  try {
    s3.listObjects("b");
  } catch (final AmazonServiceException e) {
    assertThat(e.getStatusCode(), is(404));
    assertThat(e.getErrorCode(), is("NoSuchBucket"));
    assertThat(e.getErrorType(), is(ErrorType.Client));
  }
}
 
Example #7
Source File: AmazonS3Stub.java    From aws-java-sdk-stubs with Apache License 2.0 5 votes vote down vote up
private S3ObjectInfo getObject(final String key) {
  final S3ObjectInfo info = getObjectOrNull(key);
  if (info == null) {
    final AmazonServiceException e = new AmazonServiceException("The specified key does not exist");
    e.setErrorCode("NoSuchKey");
    e.setErrorType(ErrorType.Client);
    e.setServiceName("Amazon S3");
    e.setStatusCode(404);
    throw e;
  }
  return info;
}
 
Example #8
Source File: AmazonS3Stub.java    From aws-java-sdk-stubs with Apache License 2.0 5 votes vote down vote up
private BucketInfo getBucketInfo(final String name) {
  final BucketInfo info = getBucketInfoOrNull(name);
  if (info == null) {
    final AmazonServiceException e = new AmazonServiceException("The specified bucket does not exist");
    e.setStatusCode(404);
    e.setErrorType(ErrorType.Client);
    e.setServiceName("Amazon S3");
    e.setErrorCode("NoSuchBucket");
    throw e;
  }
  return info;
}
 
Example #9
Source File: SimplifiedKinesisClientTest.java    From beam with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldHandleServiceErrorForGetBacklogBytes() {
  shouldHandleGetBacklogBytesError(
      newAmazonServiceException(ErrorType.Service), TransientKinesisException.class);
}
 
Example #10
Source File: KinesisProxyTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testIsRecoverableExceptionWithExpiredIteratorException() {
	final ExpiredIteratorException ex = new ExpiredIteratorException("asdf");
	ex.setErrorType(ErrorType.Client);
	assertFalse(KinesisProxy.isRecoverableException(ex));
}
 
Example #11
Source File: KinesisProxyTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testIsRecoverableExceptionWithServiceException() {
	final AmazonServiceException ex = new AmazonServiceException("asdf");
	ex.setErrorType(ErrorType.Service);
	assertTrue(KinesisProxy.isRecoverableException(ex));
}
 
Example #12
Source File: KinesisProxyTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testIsRecoverableExceptionWithProvisionedThroughputExceeded() {
	final ProvisionedThroughputExceededException ex = new ProvisionedThroughputExceededException("asdf");
	ex.setErrorType(ErrorType.Client);
	assertTrue(KinesisProxy.isRecoverableException(ex));
}
 
Example #13
Source File: SimplifiedKinesisClientTest.java    From beam with Apache License 2.0 4 votes vote down vote up
private AmazonServiceException newAmazonServiceException(ErrorType errorType) {
  AmazonServiceException exception = new AmazonServiceException("");
  exception.setErrorType(errorType);
  return exception;
}
 
Example #14
Source File: SimplifiedKinesisClientTest.java    From beam with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldHandleClientErrorForGetBacklogBytes() {
  shouldHandleGetBacklogBytesError(
      newAmazonServiceException(ErrorType.Client), RuntimeException.class);
}
 
Example #15
Source File: KinesisProxyTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testIsRecoverableExceptionWithProvisionedThroughputExceeded() {
	final ProvisionedThroughputExceededException ex = new ProvisionedThroughputExceededException("asdf");
	ex.setErrorType(ErrorType.Client);
	assertTrue(KinesisProxy.isRecoverableException(ex));
}
 
Example #16
Source File: SimplifiedKinesisClientTest.java    From beam with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldHandleClientErrorForShardListing() {
  shouldHandleShardListingError(
      newAmazonServiceException(ErrorType.Client), RuntimeException.class);
}
 
Example #17
Source File: SimplifiedKinesisClientTest.java    From beam with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldHandleServiceErrorForShardListing() {
  shouldHandleShardListingError(
      newAmazonServiceException(ErrorType.Service), TransientKinesisException.class);
}
 
Example #18
Source File: SimplifiedKinesisClientTest.java    From beam with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldHandleClientErrorForGetShardIterator() {
  shouldHandleGetShardIteratorError(
      newAmazonServiceException(ErrorType.Client), RuntimeException.class);
}
 
Example #19
Source File: SimplifiedKinesisClientTest.java    From beam with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldHandleServiceErrorForGetShardIterator() {
  shouldHandleGetShardIteratorError(
      newAmazonServiceException(ErrorType.Service), TransientKinesisException.class);
}
 
Example #20
Source File: KinesisProxyTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testIsRecoverableExceptionWithExpiredIteratorException() {
	final ExpiredIteratorException ex = new ExpiredIteratorException("asdf");
	ex.setErrorType(ErrorType.Client);
	assertFalse(KinesisProxy.isRecoverableException(ex));
}
 
Example #21
Source File: KinesisProxyTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testIsRecoverableExceptionWithServiceException() {
	final AmazonServiceException ex = new AmazonServiceException("asdf");
	ex.setErrorType(ErrorType.Service);
	assertTrue(KinesisProxy.isRecoverableException(ex));
}
 
Example #22
Source File: KinesisProxyTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testIsRecoverableExceptionWithProvisionedThroughputExceeded() {
	final ProvisionedThroughputExceededException ex = new ProvisionedThroughputExceededException("asdf");
	ex.setErrorType(ErrorType.Client);
	assertTrue(KinesisProxy.isRecoverableException(ex));
}
 
Example #23
Source File: KinesisProxyTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testIsRecoverableExceptionWithExpiredIteratorException() {
	final ExpiredIteratorException ex = new ExpiredIteratorException("asdf");
	ex.setErrorType(ErrorType.Client);
	assertFalse(KinesisProxy.isRecoverableException(ex));
}
 
Example #24
Source File: KinesisProxyTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testIsRecoverableExceptionWithServiceException() {
	final AmazonServiceException ex = new AmazonServiceException("asdf");
	ex.setErrorType(ErrorType.Service);
	assertTrue(KinesisProxy.isRecoverableException(ex));
}