本文整理了Java中com.amazonaws.AmazonServiceException.getMessage()
方法的一些代码示例,展示了AmazonServiceException.getMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AmazonServiceException.getMessage()
方法的具体详情如下:
包路径:com.amazonaws.AmazonServiceException
类名称:AmazonServiceException
方法名:getMessage
暂无
代码示例来源:origin: awsdocs/aws-doc-sdk-examples
public static void waitForCompletion(Transfer xfer)
{
try {
xfer.waitForCompletion();
} catch (AmazonServiceException e) {
System.err.println("Amazon service error: " + e.getMessage());
System.exit(1);
} catch (AmazonClientException e) {
System.err.println("Amazon client error: " + e.getMessage());
System.exit(1);
} catch (InterruptedException e) {
System.err.println("Transfer interrupted: " + e.getMessage());
System.exit(1);
}
}
代码示例来源:origin: apache/nifi
protected List<FlowFile> processServiceException(final ProcessSession session, List<FlowFile> flowFiles,
AmazonServiceException exception) {
List<FlowFile> failedFlowFiles = new ArrayList<>();
for (FlowFile flowFile : flowFiles) {
Map<String,String> attributes = new HashMap<>();
attributes.put(DYNAMODB_ERROR_EXCEPTION_MESSAGE, exception.getMessage() );
attributes.put(DYNAMODB_ERROR_CODE, exception.getErrorCode() );
attributes.put(DYNAMODB_ERROR_MESSAGE, exception.getErrorMessage() );
attributes.put(DYNAMODB_ERROR_TYPE, exception.getErrorType().name() );
attributes.put(DYNAMODB_ERROR_SERVICE, exception.getServiceName() );
attributes.put(DYNAMODB_ERROR_RETRYABLE, Boolean.toString(exception.isRetryable()));
attributes.put(DYNAMODB_ERROR_REQUEST_ID, exception.getRequestId() );
attributes.put(DYNAMODB_ERROR_STATUS_CODE, Integer.toString(exception.getStatusCode()) );
attributes.put(DYNAMODB_ERROR_EXCEPTION_MESSAGE, exception.getMessage() );
attributes.put(DYNAMODB_ERROR_RETRYABLE, Boolean.toString(exception.isRetryable()));
flowFile = session.putAllAttributes(flowFile, attributes);
failedFlowFiles.add(flowFile);
}
return failedFlowFiles;
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Retrieves an instruction file from S3; or null if no instruction file is
* found.
*
* @param s3ObjectId
* the S3 object id (not the instruction file id)
* @param instFileSuffix
* suffix of the instruction file to be retrieved; or null to use
* the default suffix.
* @return an instruction file, or null if no instruction file is found.
*/
final S3ObjectWrapper fetchInstructionFile(S3ObjectId s3ObjectId,
String instFileSuffix) {
try {
S3Object o = s3.getObject(
createInstructionGetRequest(s3ObjectId, instFileSuffix));
return o == null ? null : new S3ObjectWrapper(o, s3ObjectId);
} catch (AmazonServiceException e) {
// If no instruction file is found, log a debug message, and return
// null.
if (log.isDebugEnabled()) {
log.debug("Unable to retrieve instruction file : "
+ e.getMessage());
}
return null;
}
}
代码示例来源:origin: stackoverflow.com
System.out.println("Error Message: " + ase.getMessage());
System.out.println("HTTP Status Code: " + ase.getStatusCode());
System.out.println("AWS Error Code: " + ase.getErrorCode());
代码示例来源:origin: aws/aws-sdk-java
/**
* Asserts that the specified AmazonServiceException is valid, meaning it has a non-empty,
* non-null value for its message, requestId, etc.
*
* @param e
* The exception to validate.
*/
public static void assertValidException(AmazonServiceException e) {
assertNotNull(e.getRequestId());
assertTrue(e.getRequestId().trim().length() > 0);
assertNotNull(e.getMessage());
assertTrue(e.getMessage().trim().length() > 0);
assertNotNull(e.getErrorCode());
assertTrue(e.getErrorCode().trim().length() > 0);
assertNotNull(e.getServiceName());
assertTrue(e.getServiceName().startsWith("Amazon") || e.getServiceName().startsWith("AWS"));
}
代码示例来源:origin: awsdocs/aws-doc-sdk-examples
public static void main(String[] args) {
AmazonGuardDuty guardduty =
AmazonGuardDutyClientBuilder.defaultClient();
try {
ListDetectorsRequest request = new ListDetectorsRequest();
ListDetectorsResult response = guardduty.listDetectors(request);
for (String detectorId : response.getDetectorIds())
{
System.out.println("DetectorId: " + detectorId );
}
} catch (AmazonServiceException ase) {
System.out.println("Caught Exception: " + ase.getMessage());
System.out.println("Reponse Status Code: " + ase.getStatusCode());
System.out.println("Error Code: " + ase.getErrorCode());
System.out.println("Request ID: " + ase.getRequestId());
}
}
}
代码示例来源:origin: Netflix/Priam
@Override
public boolean doesRemoteFileExist(Path remotePath) throws BackupRestoreException {
boolean exists = false;
try {
exists = s3Client.doesObjectExist(getShard(), remotePath.toString());
} catch (AmazonServiceException ase) {
// Amazon S3 rejected request
throw new BackupRestoreException(
"AmazonServiceException while checking existence of object: "
+ remotePath
+ ". Error: "
+ ase.getMessage());
} catch (AmazonClientException ace) {
// No point throwing this exception up.
logger.error(
"AmazonClientException: client encountered a serious internal problem while trying to communicate with S3",
ace.getMessage());
}
return exists;
}
代码示例来源:origin: awsdocs/aws-doc-sdk-examples
System.out.println("Caught Exception: " + ase.getMessage());
System.out.println("Reponse Status Code: " + ase.getStatusCode());
System.out.println("Error Code: " + ase.getErrorCode());
代码示例来源:origin: aws/aws-sdk-java
} catch (AmazonServiceException ase) {
if (ase.getErrorCode().equals("DryRunOperation") && ase.getStatusCode() == 412) {
return new DryRunResult<X>(true, request, ase.getMessage(), ase);
} else if (ase.getErrorCode().equals("UnauthorizedOperation") && ase.getStatusCode() == 403) {
return new DryRunResult<X>(false, request, ase.getMessage(), ase);
} else if (ase.getErrorCode().equals("AuthFailure")) {
return new DryRunResult<X>(false, request, ase.getMessage(), ase);
代码示例来源:origin: awsdocs/aws-doc-sdk-examples
" your request made it to Amazon Step Functions, but was" +
" rejected with an error response for some reason.");
System.out.println("Error Message: " + ase.getMessage());
System.out.println("HTTP Status Code: " + ase.getStatusCode());
System.out.println("AWS Error Code: " + ase.getErrorCode());
代码示例来源:origin: apache/nifi
getLogger().error("Could not process flowFiles due to service exception : " + exception.getMessage());
List<FlowFile> failedFlowFiles = processServiceException(session, flowFiles, exception);
session.transfer(failedFlowFiles, REL_FAILURE);
代码示例来源:origin: apache/nifi
getLogger().error("Could not process flowFiles due to service exception : " + exception.getMessage());
List<FlowFile> failedFlowFiles = processServiceException(session, flowFiles, exception);
session.transfer(failedFlowFiles, REL_FAILURE);
代码示例来源:origin: apache/nifi
getLogger().error("Could not process flowFiles due to service exception : " + exception.getMessage());
List<FlowFile> failedFlowFiles = processServiceException(session, flowFiles, exception);
session.transfer(failedFlowFiles, REL_FAILURE);
代码示例来源:origin: aws-amplify/aws-sdk-android
int parseClockSkewOffset(HttpResponse response, AmazonServiceException exception) {
final Date deviceDate = new Date();
Date serverDate = null;
String serverDateStr = null;
final String responseDateHeader = response.getHeaders().get("Date");
try {
if (responseDateHeader == null || responseDateHeader.isEmpty()) {
// SQS doesn't return Date header
serverDateStr = getServerDateFromException(exception.getMessage());
serverDate = DateUtils.parseCompressedISO8601Date(serverDateStr);
} else {
serverDateStr = responseDateHeader;
serverDate = DateUtils.parseRFC822Date(serverDateStr);
}
} catch (final RuntimeException e) {
log.warn("Unable to parse clock skew offset from response: "
+ serverDateStr,
e);
return 0;
}
final long diff = deviceDate.getTime() - serverDate.getTime();
return (int) (diff / TIME_MILLISEC);
}
代码示例来源:origin: aws-amplify/aws-sdk-android
"Unable to successfully deliver events to server. Events will be saved, error likely recoverable. Response status code "
+ e.getStatusCode() + " , response error code " + e.getErrorCode()
+ e.getMessage());
Log.w(TAG, "Recieved an error response: " + e.getMessage());
代码示例来源:origin: aws-amplify/aws-sdk-android
} catch (AmazonServiceException ase) {
if (ase.getErrorCode().equals("DryRunOperation") && ase.getStatusCode() == 412) {
return new DryRunResult<X>(true, request, ase.getMessage(), ase);
} else if (ase.getErrorCode().equals("UnauthorizedOperation") && ase.getStatusCode() == 403) {
return new DryRunResult<X>(false, request, ase.getMessage(), ase);
代码示例来源:origin: aws-amplify/aws-sdk-android
/**
* Retrieves an instruction file from S3; or null if no instruction file is
* found.
*
* @param s3ObjectId
* the S3 object id (not the instruction file id)
* @param instFileSuffix
* suffix of the instruction file to be retrieved; or null to use
* the default suffix.
* @return an instruction file, or null if no instruction file is found.
*/
final S3ObjectWrapper fetchInstructionFile(S3ObjectId s3ObjectId,
String instFileSuffix) {
try {
final S3Object o = s3.getObject(
createInstructionGetRequest(s3ObjectId, instFileSuffix));
return o == null ? null : new S3ObjectWrapper(o, s3ObjectId);
} catch (final AmazonServiceException e) {
// If no instruction file is found, log a debug message, and return
// null.
if (log.isDebugEnabled()) {
log.debug("Unable to retrieve instruction file : "
+ e.getMessage());
}
return null;
}
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testJsonExceptionUnmarshallerWithAdditionalFields() throws Exception {
HttpResponse response = HttpResponse.builder()
.content(new ByteArrayInputStream(errorResponse.getBytes("UTF-8")))
.build();
JsonErrorResponse error = JsonErrorResponse.fromResponse(response);
AmazonServiceException ase = new InternalServerErrorExceptionUnmarshaller()
.unmarshall(error);
assertTrue(ase instanceof InternalServerErrorException);
assertEquals("value1", ((InternalServerErrorException) ase).getField1());
assertEquals("value2", ((InternalServerErrorException) ase).getField2());
assertEquals("InternalServerError", ase.getErrorCode());
assertEquals("Requested resource not found "
+ "(Service: null; "
+ "Status Code: 0; "
+ "Error Code: InternalServerError; "
+ "Request ID: null)",
ase.getMessage());
}
代码示例来源:origin: org.duracloud/s3storageprovider
private static AmazonCloudFrontClient newAmazonCloudFrontClient(String accessKey,
String secretKey) {
BasicAWSCredentials awsCredentials =
new BasicAWSCredentials(accessKey, secretKey);
try {
return new AmazonCloudFrontClient(awsCredentials);
} catch (AmazonServiceException e) {
String err = "Could not create connection to Amazon CloudFront " +
"due to error: " + e.getMessage();
throw new StorageException(err, e, RETRY);
}
}
代码示例来源:origin: stackoverflow.com
public static DynamoDB getDynamoDBConnection()
throws ApplicationSpecificException {
try {
return new DynamoDB(new AmazonDynamoDBClient(
new ProfileCredentialsProvider()));
} catch(AmazonServiceException ase) {
slf4jLogger.error(ase.getMessage());
slf4jLogger.error(ase.getStackTrace());
slf4jLogger.error(ase);
throw new ApplicationSpecificException("some good message", ase);
}
}
内容来源于网络,如有侵权,请联系作者删除!