本文整理了Java中com.amazonaws.http.AmazonHttpClient.handleErrorResponse()
方法的一些代码示例,展示了AmazonHttpClient.handleErrorResponse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AmazonHttpClient.handleErrorResponse()
方法的具体详情如下:
包路径:com.amazonaws.http.AmazonHttpClient
类名称:AmazonHttpClient
方法名:handleErrorResponse
[英]Responsible for handling an error response, including unmarshalling the error response into the most specific exception type possible, and throwing the exception.
[中]负责处理错误响应,包括将错误响应解组为可能的最特定异常类型,并引发异常。
代码示例来源:origin: aws-amplify/aws-sdk-android
} else {
leaveHttpConnectionOpen = errorResponseHandler.needsConnectionLeftOpen();
final AmazonServiceException ase = handleErrorResponse(request, errorResponseHandler,
httpResponse);
awsRequestMetrics.addProperty(Field.AWSRequestID, ase.getRequestId());
代码示例来源:origin: aws-amplify/aws-sdk-android
@Test(expected = AmazonClientException.class)
public void testHandleErrorResponseHandlerFailsWithUnknownException() throws IOException {
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);
throw new Exception("test");
}
@Override
public boolean needsConnectionLeftOpen() {
return false;
}
};
AmazonServiceException e = client.handleErrorResponse(request, errorResponseHandler,
httpResponse);
}
代码示例来源: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 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: 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.gluonhq/aws-java-sdk-core
} else {
leaveHttpConnectionOpen = errorResponseHandler.needsConnectionLeftOpen();
final AmazonServiceException ase = handleErrorResponse(request, errorResponseHandler,
httpResponse);
awsRequestMetrics.addProperty(Field.AWSRequestID, ase.getRequestId());
代码示例来源:origin: com.amazonaws/aws-android-sdk-core
} else {
leaveHttpConnectionOpen = errorResponseHandler.needsConnectionLeftOpen();
final AmazonServiceException ase = handleErrorResponse(request, errorResponseHandler,
httpResponse);
awsRequestMetrics.addProperty(Field.AWSRequestID, ase.getRequestId());
内容来源于网络,如有侵权,请联系作者删除!