本文整理了Java中com.amazonaws.AmazonServiceException.getErrorType()
方法的一些代码示例,展示了AmazonServiceException.getErrorType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AmazonServiceException.getErrorType()
方法的具体详情如下:
包路径:com.amazonaws.AmazonServiceException
类名称:AmazonServiceException
方法名:getErrorType
[英]Indicates who is responsible for this exception (caller, service, or unknown).
[中]指示谁对此异常负责(调用方、服务或未知)。
代码示例来源: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: apache/nifi
/**
* Populate exception attributes in the flow file
* @param session process session
* @param flowFile the flow file
* @param exception exception thrown during invocation
* @return FlowFile the updated flow file
*/
private FlowFile populateExceptionAttributes(final ProcessSession session, FlowFile flowFile,
final AmazonServiceException exception) {
Map<String,String> attributes = new HashMap<>();
attributes.put(AWS_LAMBDA_EXCEPTION_MESSAGE, exception.getErrorMessage());
attributes.put(AWS_LAMBDA_EXCEPTION_ERROR_CODE, exception.getErrorCode());
attributes.put(AWS_LAMBDA_EXCEPTION_REQUEST_ID, exception.getRequestId());
attributes.put(AWS_LAMBDA_EXCEPTION_STATUS_CODE, Integer.toString(exception.getStatusCode()));
if ( exception.getCause() != null )
attributes.put(AWS_LAMBDA_EXCEPTION_CAUSE, exception.getCause().getMessage());
attributes.put(AWS_LAMBDA_EXCEPTION_ERROR_TYPE, exception.getErrorType().toString());
attributes.put(AWS_LAMBDA_EXCEPTION_MESSAGE, exception.getErrorMessage());
flowFile = session.putAllAttributes(flowFile, attributes);
return flowFile;
}
代码示例来源:origin: stackoverflow.com
System.out.println("HTTP Status Code: " + ase.getStatusCode());
System.out.println("AWS Error Code: " + ase.getErrorCode());
System.out.println("Error Type: " + ase.getErrorType());
System.out.println("Request ID: " + ase.getRequestId());
} catch (AmazonClientException ace) {
代码示例来源:origin: awsdocs/aws-doc-sdk-examples
System.out.println("HTTP Status Code: " + ase.getStatusCode());
System.out.println("AWS Error Code: " + ase.getErrorCode());
System.out.println("Error Type: " + ase.getErrorType());
System.out.println("Request ID: " + ase.getRequestId());
} catch (AmazonClientException ace) {
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testUnmarshall() throws TransformerFactoryConfigurationError, Exception {
Document xmlDoc = new DocumentImpl();
Element root = xmlDoc.createElement("ErrorResponse");
Element requestId = xmlDoc.createElement("RequestId");
requestId.appendChild(xmlDoc.createTextNode("TestId"));
Element error = xmlDoc.createElement("Error");
Element message = xmlDoc.createElement("Message");
message.appendChild(xmlDoc.createTextNode("TestMessage"));
Element type = xmlDoc.createElement("Type");
type.appendChild(xmlDoc.createTextNode("Receiver"));
error.appendChild(message);
error.appendChild(type);
root.appendChild(error);
root.appendChild(requestId);
xmlDoc.appendChild(root);
StandardErrorUnmarshaller seu = new StandardErrorUnmarshaller();
AmazonServiceException ase = seu.unmarshall(xmlDoc);
assertEquals(ase.getErrorMessage(), "TestMessage");
assertEquals(ase.getErrorType(), ErrorType.Service);
assertEquals(ase.getRequestId(), "TestId");
Element code = xmlDoc.createElement("Code");
code.appendChild(xmlDoc.createTextNode("TestCode"));
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testUnmarshall() throws TransformerFactoryConfigurationError, Exception {
Document xmlDoc = new DocumentImpl();
Element root = xmlDoc.createElement("Response");
Element requestId = xmlDoc.createElement("RequestID");
requestId.appendChild(xmlDoc.createTextNode("TestId"));
Element errors = xmlDoc.createElement("Errors");
Element error = xmlDoc.createElement("Error");
Element message = xmlDoc.createElement("Message");
message.appendChild(xmlDoc.createTextNode("TestMessage"));
Element type = xmlDoc.createElement("Type");
type.appendChild(xmlDoc.createTextNode("server"));
Element code = xmlDoc.createElement("Code");
code.appendChild(xmlDoc.createTextNode("TestCode"));
error.appendChild(message);
error.appendChild(type);
error.appendChild(code);
errors.appendChild(error);
root.appendChild(errors);
root.appendChild(requestId);
xmlDoc.appendChild(root);
LegacyErrorUnmarshaller leu = new LegacyErrorUnmarshaller();
AmazonServiceException ase = leu.unmarshall(xmlDoc);
assertEquals(ase.getErrorCode(), "TestCode");
assertEquals(ase.getErrorMessage(), "TestMessage");
assertEquals(ase.getErrorType(), ErrorType.Service);
assertEquals(ase.getRequestId(), "TestId");
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testJsonErrorResponseReturnsServiceErrorTypeIfErrorStatus5XX() throws Exception {
List<JsonErrorUnmarshaller> exceptionUnmarshallers = new ArrayList<JsonErrorUnmarshaller>();
exceptionUnmarshallers.add(new JsonErrorUnmarshaller() {
@Override
public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception {
return new AmazonServiceException("TestException");
}
});
handler = new JsonErrorResponseHandler(exceptionUnmarshallers);
response = HttpResponse.builder()
.statusCode(500)
.content(new ByteArrayInputStream("{}".getBytes(StringUtils.UTF8)))
.build();
AmazonServiceException returnedException = handler.handle(response);
assertEquals(returnedException.getErrorType(), ErrorType.Service);
}
代码示例来源:origin: Aloisius/hadoop-s3a
private void printAmazonServiceException(AmazonServiceException ase) {
LOG.info("Caught an AmazonServiceException, which means your request made it " +
"to Amazon S3, but was rejected with an error response for some reason.");
LOG.info("Error Message: " + ase.getMessage());
LOG.info("HTTP Status Code: " + ase.getStatusCode());
LOG.info("AWS Error Code: " + ase.getErrorCode());
LOG.info("Error Type: " + ase.getErrorType());
LOG.info("Request ID: " + ase.getRequestId());
LOG.info("Class Name: " + ase.getClass().getName());
}
代码示例来源:origin: org.jasig.portal/uPortal-portlets
private void logAmazonServiceException(
final AmazonServiceException exception, final AmazonWebServiceRequest request) {
log.info(
"Caught an AmazonServiceException, which means your request made it "
+ "to Amazon S3, but was rejected with an error response for some reason.");
log.info("Error Message: {}", exception.getMessage());
log.info("HTTP Status Code: {}", exception.getStatusCode());
log.info("AWS Error Code: {}", exception.getErrorCode());
log.info("Error Type: {}", exception.getErrorType());
log.info("Request ID: {}", exception.getRequestId());
}
代码示例来源:origin: Netflix/ndbench
protected AmazonServiceException amazonServiceException(AmazonServiceException ase) {
logger.error("Caught an AmazonServiceException, which means your request made it "
+ "to AWS, but was rejected with an error response for some reason.");
logger.error("Error Message: " + ase.getMessage());
logger.error("HTTP Status Code: " + ase.getStatusCode());
logger.error("AWS Error Code: " + ase.getErrorCode());
logger.error("Error Type: " + ase.getErrorType());
logger.error("Request ID: " + ase.getRequestId());
return ase;
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testDefaultErrorResponseHandlerCannotGetContent() throws Exception {
List<Unmarshaller<AmazonServiceException, Node>> unmarshallerList = new ArrayList<Unmarshaller<AmazonServiceException, Node>>();
HttpResponse errorResponse = new HttpResponse.Builder()
.statusCode(400)
.statusText("Error")
.content(new InputStream() {
@Override
public int read() throws IOException {
throw new IOException("Test IOException");
}
})
.build();
DefaultErrorResponseHandler handler = new DefaultErrorResponseHandler(unmarshallerList);
AmazonServiceException e = handler.handle(errorResponse);
assertEquals(e.getErrorCode(),
errorResponse.getStatusCode() + " " + errorResponse.getStatusText());
assertEquals(e.getStatusCode(), 400);
assertEquals(e.getErrorType(), ErrorType.Unknown);
}
代码示例来源:origin: ch.cern.hadoop/hadoop-aws
private void printAmazonServiceException(AmazonServiceException ase) {
LOG.info("Caught an AmazonServiceException {}", ase.toString());
LOG.info("Error Message: {}", ase.getMessage());
LOG.info("HTTP Status Code: {}", ase.getStatusCode());
LOG.info("AWS Error Code: {}", ase.getErrorCode());
LOG.info("Error Type: {}", ase.getErrorType());
LOG.info("Request ID: {}", ase.getRequestId());
LOG.info("Stack", ase);
}
}
代码示例来源:origin: com.netflix.spinnaker.kork/kork-core
static String[] buildExceptionTags(AmazonWebServiceRequest originalRequest, Exception exception) {
final AmazonServiceException ase = amazonServiceException(exception);
String targetAccountId = DEFAULT_UNKNOWN;
if (ase.getHttpHeaders() != null) {
targetAccountId = ase.getHttpHeaders().get("targetAccountId");
}
return new String[] {
"requestType", originalRequest.getClass().getSimpleName(),
"statusCode", Integer.toString(ase.getStatusCode()),
"errorCode", Optional.ofNullable(ase.getErrorCode()).orElse(DEFAULT_UNKNOWN),
"serviceName", Optional.ofNullable(ase.getServiceName()).orElse(DEFAULT_UNKNOWN),
"errorType", Optional.ofNullable(ase.getErrorType()).orElse(AmazonServiceException.ErrorType.Unknown).name(),
"accountId", Optional.ofNullable(targetAccountId).orElse(DEFAULT_UNKNOWN)
};
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testHandleErrorResponseHandlerFailsWith413() throws IOException {
Request<?> request = new DefaultRequest<String>("ServiceName");
final HttpResponse httpResponse = new HttpResponse.Builder().statusText("TestResponse")
.statusCode(413).build();
HttpResponseHandler<AmazonServiceException> errorResponseHandler = new HttpResponseHandler<AmazonServiceException>() {
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
assertSame(response, httpResponse);
throw new Exception("test");
}
@Override
public boolean needsConnectionLeftOpen() {
return false;
}
};
AmazonServiceException e = client.handleErrorResponse(request, errorResponseHandler,
httpResponse);
assertEquals(e.getStatusCode(), 413);
assertEquals(e.getErrorCode(), "Request entity too large");
assertEquals(e.getErrorType(), ErrorType.Client);
assertEquals(e.getServiceName(), "ServiceName");
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testHandleErrorResponseHandlerFailsWith503() throws IOException {
Request<?> request = new DefaultRequest<String>("ServiceName");
final HttpResponse httpResponse = new HttpResponse.Builder()
.statusText("Service unavailable")
.statusCode(503).build();
HttpResponseHandler<AmazonServiceException> errorResponseHandler = new HttpResponseHandler<AmazonServiceException>() {
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
assertSame(response, httpResponse);
throw new Exception("test");
}
@Override
public boolean needsConnectionLeftOpen() {
return false;
}
};
AmazonServiceException e = client.handleErrorResponse(request, errorResponseHandler,
httpResponse);
assertEquals(e.getStatusCode(), 503);
assertEquals(e.getErrorCode(), "Service unavailable");
assertEquals(e.getErrorType(), ErrorType.Service);
assertEquals(e.getServiceName(), "ServiceName");
}
代码示例来源:origin: com.erudika/para-server
private static void logException(AmazonServiceException ase) {
logger.error("AmazonServiceException: error={}, statuscode={}, awserrcode={}, errtype={}, reqid={}",
ase.toString(), ase.getStatusCode(), ase.getErrorCode(), ase.getErrorType(), ase.getRequestId());
}
代码示例来源:origin: com.erudika/para
private void logException(AmazonServiceException ase) {
logger.error("AmazonServiceException: error={}, statuscode={}, "
+ "awserrcode={}, errtype={}, reqid={}", ase.toString(), ase.getStatusCode(),
ase.getErrorCode(), ase.getErrorType(), ase.getRequestId());
}
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test
public void testHandleErrorResponse() throws IOException {
final Request<?> request = new DefaultRequest<String>("ServiceName");
final HttpResponse httpResponse = new HttpResponse.Builder().statusText("TestResponse")
.statusCode(400).build();
HttpResponseHandler<AmazonServiceException> errorResponseHandler = new HttpResponseHandler<AmazonServiceException>() {
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
assertSame(response, httpResponse);
AmazonServiceException ase = new AmazonServiceException("Test");
ase.setErrorCode("TestError");
ase.setErrorType(ErrorType.Service);
ase.setServiceName(request.getServiceName());
ase.setStatusCode(response.getStatusCode());
return ase;
}
@Override
public boolean needsConnectionLeftOpen() {
return false;
}
};
AmazonServiceException e = client.handleErrorResponse(request, errorResponseHandler,
httpResponse);
assertEquals(e.getStatusCode(), 400);
assertEquals(e.getErrorCode(), "TestError");
assertEquals(e.getErrorType(), ErrorType.Service);
assertEquals(e.getServiceName(), "ServiceName");
}
代码示例来源:origin: Erudika/para
private static void logException(AmazonServiceException ase) {
logger.error("AmazonServiceException: error={}, statuscode={}, awserrcode={}, errtype={}, reqid={}",
ase.toString(), ase.getStatusCode(), ase.getErrorCode(), ase.getErrorType(), ase.getRequestId());
}
代码示例来源:origin: stackoverflow.com
String parseError(AmazonServiceException ase){
String message;
message = "Caught an AmazonServiceException, which means your request made it "
+ "to Amazon S3, but was rejected with an error response for some reason.";
message += "Error Message: " + ase.getMessage();
message += "HTTP Status Code: " + ase.getStatusCode();
message += "AWS Error Code: " + ase.getErrorCode();
message += "Error Type: " + ase.getErrorType();
message += "Request ID: " + ase.getRequestId();
return message;
}
String parseError(AmazonClientException ace){
String message;
message = "Caught an AmazonClientException, which means the client encountered "
+ "a serious internal problem while trying to communicate with S3, "
+ "such as not being able to access the network.";
message += "Error Message: " + ace.getMessage();
return message;
}
内容来源于网络,如有侵权,请联系作者删除!