本文整理了Java中com.amazonaws.AmazonServiceException.setErrorType()
方法的一些代码示例,展示了AmazonServiceException.setErrorType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AmazonServiceException.setErrorType()
方法的具体详情如下:
包路径:com.amazonaws.AmazonServiceException
类名称:AmazonServiceException
方法名:setErrorType
[英]Sets the type of error represented by this exception (sender, receiver, or unknown), indicating if this exception was the caller's fault, or the service's fault.
[中]设置此异常(发送方、接收方或未知)表示的错误类型,指示此异常是调用方的错误还是服务的错误。
代码示例来源:origin: aws/aws-sdk-java
@Override
public AmazonServiceException unmarshall(Node in) throws Exception {
XPath xpath = xpath();
String errorCode = parseErrorCode(in, xpath);
String message = asString("Response/Errors/Error/Message", in, xpath);
String requestId = asString("Response/RequestID", in, xpath);
String errorType = asString("Response/Errors/Error/Type", in, xpath);
Constructor<? extends AmazonServiceException> constructor = exceptionClass.getConstructor(String.class);
AmazonServiceException ase = constructor.newInstance(message);
ase.setErrorCode(errorCode);
ase.setRequestId(requestId);
if (errorType == null) {
ase.setErrorType(ErrorType.Unknown);
} else if (errorType.equalsIgnoreCase("server")) {
ase.setErrorType(ErrorType.Service);
} else if (errorType.equalsIgnoreCase("client")) {
ase.setErrorType(ErrorType.Client);
}
return ase;
}
代码示例来源:origin: aws/aws-sdk-java
/**
* @see com.amazonaws.transform.Unmarshaller#unmarshall(java.lang.Object)
*/
public AmazonServiceException unmarshall(Node in) throws Exception {
XPath xpath = xpath();
String errorCode = parseErrorCode(in, xpath);
String errorType = asString("ErrorResponse/Error/Type", in, xpath);
String requestId = asString("ErrorResponse/RequestId", in, xpath);
String message = asString("ErrorResponse/Error/Message", in, xpath);
AmazonServiceException ase = newException(message);
ase.setErrorCode(errorCode);
ase.setRequestId(requestId);
if (errorType == null) {
ase.setErrorType(ErrorType.Unknown);
} else if (errorType.equalsIgnoreCase("Receiver")) {
ase.setErrorType(ErrorType.Service);
} else if (errorType.equalsIgnoreCase("Sender")) {
ase.setErrorType(ErrorType.Client);
}
return ase;
}
代码示例来源:origin: aws/aws-sdk-java
static Exception convert(BatchResultErrorEntry be) {
AmazonServiceException toReturn = new AmazonServiceException(be.getMessage());
toReturn.setErrorCode(be.getCode());
toReturn.setErrorType(be.isSenderFault() ? ErrorType.Client : ErrorType.Service);
toReturn.setServiceName("AmazonSQS");
return toReturn;
}
代码示例来源:origin: aws/aws-sdk-java
private AmazonServiceException handleAse(HttpResponse response) throws Exception {
final int statusCode = response.getStatusCode();
try {
return delegate.handle(response);
} catch(InterruptedException e) {
throw e;
} catch (Exception e) {
// If the errorResponseHandler doesn't work, then check for error responses that don't have any content
if (statusCode == 413) {
AmazonServiceException exception = new AmazonServiceException("Request entity too large");
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Client);
exception.setErrorCode("Request entity too large");
return exception;
} else if (statusCode >= 500 && statusCode < 600) {
AmazonServiceException exception = new AmazonServiceException(response.getStatusText());
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Service);
exception.setErrorCode(response.getStatusText());
return exception;
} else {
throw e;
}
}
}
代码示例来源:origin: aws/aws-sdk-java
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
JsonContent jsonContent = JsonContent.createJsonContent(response, jsonFactory);
String errorCode = errorCodeParser.parseErrorCode(response, jsonContent);
AmazonServiceException ase = createException(errorCode, jsonContent);
// Jackson has special-casing for 'message' values when deserializing
// Throwables, but sometimes the service passes the error message in
// other JSON fields - handle it here.
if (ase.getErrorMessage() == null) {
ase.setErrorMessage(errorMessageParser.parseErrorMessage(response, jsonContent.getJsonNode()));
}
ase.setErrorCode(errorCode);
ase.setServiceName(response.getRequest().getServiceName());
ase.setStatusCode(response.getStatusCode());
ase.setErrorType(getErrorTypeFromStatusCode(response.getStatusCode()));
ase.setRawResponse(jsonContent.getRawContent());
String requestId = getRequestIdFromHeaders(response.getHeaders());
if (requestId != null) {
ase.setRequestId(requestId);
}
ase.setHttpHeaders(response.getHeaders());
return ase;
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Override
public AmazonServiceException unmarshall(Node in) throws Exception {
String errorCode = parseErrorCode(in);
String message = XpathUtils.asString("Response/Errors/Error/Message", in);
String requestId = XpathUtils.asString("Response/RequestID", in);
String errorType = XpathUtils.asString("Response/Errors/Error/Type", in);
Constructor<? extends AmazonServiceException> constructor = exceptionClass
.getConstructor(String.class);
AmazonServiceException ase = constructor.newInstance(message);
ase.setErrorCode(errorCode);
ase.setRequestId(requestId);
if (errorType == null) {
ase.setErrorType(ErrorType.Unknown);
} else if ("server".equalsIgnoreCase(errorType)) {
ase.setErrorType(ErrorType.Service);
} else if ("client".equalsIgnoreCase(errorType)) {
ase.setErrorType(ErrorType.Client);
}
return ase;
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
@Override
public AmazonServiceException unmarshall(Node in) throws Exception {
XPath xpath = xpath();
String errorCode = parseErrorCode(in, xpath);
String message = asString("Response/Errors/Error/Message", in, xpath);
String requestId = asString("Response/RequestID", in, xpath);
String errorType = asString("Response/Errors/Error/Type", in, xpath);
Constructor<? extends AmazonServiceException> constructor = exceptionClass.getConstructor(String.class);
AmazonServiceException ase = constructor.newInstance(message);
ase.setErrorCode(errorCode);
ase.setRequestId(requestId);
if (errorType == null) {
ase.setErrorType(ErrorType.Unknown);
} else if (errorType.equalsIgnoreCase("server")) {
ase.setErrorType(ErrorType.Service);
} else if (errorType.equalsIgnoreCase("client")) {
ase.setErrorType(ErrorType.Client);
}
return ase;
}
代码示例来源:origin: aws-amplify/aws-sdk-android
/**
* @see com.amazonaws.transform.Unmarshaller#unmarshall(java.lang.Object)
*/
@Override
public AmazonServiceException unmarshall(Node in) throws Exception {
String errorCode = parseErrorCode(in);
String errorType = XpathUtils.asString("ErrorResponse/Error/Type", in);
String requestId = XpathUtils.asString("ErrorResponse/RequestId", in);
String message = XpathUtils.asString("ErrorResponse/Error/Message", in);
AmazonServiceException ase = newException(message);
ase.setErrorCode(errorCode);
ase.setRequestId(requestId);
if (errorType == null) {
ase.setErrorType(ErrorType.Unknown);
} else if ("Receiver".equalsIgnoreCase(errorType)) {
ase.setErrorType(ErrorType.Service);
} else if ("Sender".equalsIgnoreCase(errorType)) {
ase.setErrorType(ErrorType.Client);
}
return ase;
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
/**
* @see com.amazonaws.transform.Unmarshaller#unmarshall(java.lang.Object)
*/
public AmazonServiceException unmarshall(Node in) throws Exception {
XPath xpath = xpath();
String errorCode = parseErrorCode(in, xpath);
String errorType = asString("ErrorResponse/Error/Type", in, xpath);
String requestId = asString("ErrorResponse/RequestId", in, xpath);
String message = asString("ErrorResponse/Error/Message", in, xpath);
AmazonServiceException ase = newException(message);
ase.setErrorCode(errorCode);
ase.setRequestId(requestId);
if (errorType == null) {
ase.setErrorType(ErrorType.Unknown);
} else if (errorType.equalsIgnoreCase("Receiver")) {
ase.setErrorType(ErrorType.Service);
} else if (errorType.equalsIgnoreCase("Sender")) {
ase.setErrorType(ErrorType.Client);
}
return ase;
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
JsonErrorResponse error;
try {
error = JsonErrorResponse.fromResponse(response);
} catch (IOException e) {
throw new AmazonClientException("Unable to parse error response", e);
}
AmazonServiceException ase = runErrorUnmarshallers(error);
if (ase == null)
return null;
ase.setStatusCode(response.getStatusCode());
if (response.getStatusCode() < HTTP_STATUS_INTERNAL_SERVER_ERROR) {
ase.setErrorType(ErrorType.Client);
} else {
ase.setErrorType(ErrorType.Service);
}
ase.setErrorCode(error.getErrorCode());
for (Entry<String, String> headerEntry : response.getHeaders().entrySet()) {
if ("X-Amzn-RequestId".equalsIgnoreCase(headerEntry.getKey())) {
ase.setRequestId(headerEntry.getValue());
}
}
return ase;
}
代码示例来源:origin: aws-amplify/aws-sdk-android
/**
* Used to create an {@link newAmazonServiceException} when we failed to
* read the error response or parsed the error response as XML.
*/
private AmazonServiceException newAmazonServiceException(String errmsg,
HttpResponse httpResponse, Exception readFailure) {
AmazonServiceException exception = new AmazonServiceException(errmsg, readFailure);
final int statusCode = httpResponse.getStatusCode();
exception.setErrorCode(statusCode + " " + httpResponse.getStatusText());
exception.setErrorType(AmazonServiceException.ErrorType.Unknown);
exception.setStatusCode(statusCode);
return exception;
}
代码示例来源:origin: aws-amplify/aws-sdk-android
static Exception convert(BatchResultErrorEntry be)
{
AmazonServiceException toReturn = new AmazonServiceException(be.getMessage());
toReturn.setErrorCode(be.getCode());
toReturn.setErrorType(be.isSenderFault() ? ErrorType.Client : ErrorType.Service);
toReturn.setServiceName("AmazonSQS");
return toReturn;
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
private AmazonServiceException handleAse(HttpResponse response) throws Exception {
final int statusCode = response.getStatusCode();
try {
return delegate.handle(response);
} catch(InterruptedException e) {
throw e;
} catch (Exception e) {
// If the errorResponseHandler doesn't work, then check for error responses that don't have any content
if (statusCode == 413) {
AmazonServiceException exception = new AmazonServiceException("Request entity too large");
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Client);
exception.setErrorCode("Request entity too large");
return exception;
} else if (statusCode >= 500 && statusCode < 600) {
AmazonServiceException exception = new AmazonServiceException(response.getStatusText());
exception.setServiceName(response.getRequest().getServiceName());
exception.setStatusCode(statusCode);
exception.setErrorType(AmazonServiceException.ErrorType.Service);
exception.setErrorCode(response.getStatusText());
return exception;
} else {
throw e;
}
}
}
代码示例来源:origin: aws-amplify/aws-sdk-android
exception.setServiceName(request.getServiceName());
exception.setStatusCode(HTTP_STATUS_REQ_TOO_LONG);
exception.setErrorType(ErrorType.Client);
exception.setErrorCode("Request entity too large");
} else if (status == HTTP_STATUS_SERVICE_UNAVAILABLE
exception.setServiceName(request.getServiceName());
exception.setStatusCode(HTTP_STATUS_SERVICE_UNAVAILABLE);
exception.setErrorType(ErrorType.Service);
exception.setErrorCode("Service unavailable");
} else if (e instanceof IOException) {
代码示例来源:origin: aws-amplify/aws-sdk-android
@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;
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-core
@Override
public AmazonServiceException handle(HttpResponse response) throws Exception {
JsonContent jsonContent = JsonContent.createJsonContent(response, jsonFactory);
String errorCode = errorCodeParser.parseErrorCode(response, jsonContent);
AmazonServiceException ase = createException(errorCode, jsonContent);
// Jackson has special-casing for 'message' values when deserializing
// Throwables, but sometimes the service passes the error message in
// other JSON fields - handle it here.
if (ase.getErrorMessage() == null) {
ase.setErrorMessage(errorMessageParser.parseErrorMessage(response, jsonContent.getJsonNode()));
}
ase.setErrorCode(errorCode);
ase.setServiceName(response.getRequest().getServiceName());
ase.setStatusCode(response.getStatusCode());
ase.setErrorType(getErrorTypeFromStatusCode(response.getStatusCode()));
ase.setRawResponse(jsonContent.getRawContent());
String requestId = getRequestIdFromHeaders(response.getHeaders());
if (requestId != null) {
ase.setRequestId(requestId);
}
ase.setHttpHeaders(response.getHeaders());
return ase;
}
代码示例来源:origin: com.netflix.spinnaker.kork/kork-core
static AmazonServiceException amazonServiceException(Exception exception, String serviceName, int statusCode) {
if (exception instanceof AmazonServiceException) {
return (AmazonServiceException) exception;
}
final AmazonServiceException ase = new AmazonServiceException(exception.getMessage(), exception);
ase.setStatusCode(statusCode);
ase.setErrorCode(DEFAULT_UNKNOWN);
ase.setServiceName(serviceName);
ase.setErrorType(AmazonServiceException.ErrorType.Unknown);
return ase;
}
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-io-kinesis
private AmazonServiceException newAmazonServiceException(ErrorType errorType) {
AmazonServiceException exception = new AmazonServiceException("");
exception.setErrorType(errorType);
return exception;
}
代码示例来源:origin: com.amazonaws/aws-java-sdk-sqs
static Exception convert(BatchResultErrorEntry be) {
AmazonServiceException toReturn = new AmazonServiceException(be.getMessage());
toReturn.setErrorCode(be.getCode());
toReturn.setErrorType(be.isSenderFault() ? ErrorType.Client : ErrorType.Service);
toReturn.setServiceName("AmazonSQS");
return toReturn;
}
代码示例来源:origin: com.amazonaws/aws-android-sdk-sqs
static Exception convert(BatchResultErrorEntry be)
{
AmazonServiceException toReturn = new AmazonServiceException(be.getMessage());
toReturn.setErrorCode(be.getCode());
toReturn.setErrorType(be.isSenderFault() ? ErrorType.Client : ErrorType.Service);
toReturn.setServiceName("AmazonSQS");
return toReturn;
}
内容来源于网络,如有侵权,请联系作者删除!