本文整理了Java中com.amazonaws.AmazonServiceException.setRequestId()
方法的一些代码示例,展示了AmazonServiceException.setRequestId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AmazonServiceException.setRequestId()
方法的具体详情如下:
包路径:com.amazonaws.AmazonServiceException
类名称:AmazonServiceException
方法名:setRequestId
[英]Sets the AWS requestId for this exception.
[中]设置此异常的AWS requestId。
代码示例来源: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
@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
@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
/**
* @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: 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.amazonaws/aws-android-sdk-core
@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.gluonhq/aws-java-sdk-core
@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: Nextdoor/bender
@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: com.amazonaws/aws-hal-client-java
public AmazonServiceException handle(HttpResponse response)
throws Exception {
JSONObject jsonBody = getBodyAsJson(response);
Class<? extends AmazonServiceException> exceptionClass = exceptionClasses.get(response.getStatusCode());
AmazonServiceException result;
// Support other attribute names for the message?
// TODO: Inspect exception type (caching details) and apply other values from the body
String message = jsonBody.has("message") ? jsonBody.getString("message") : jsonBody.getString("Message");
if (exceptionClass != null) {
result = exceptionClass.getConstructor(String.class).newInstance(message);
} else {
result = AmazonServiceException.class.getConstructor(String.class).newInstance(message);
}
result.setServiceName(response.getRequest().getServiceName());
result.setStatusCode(response.getStatusCode());
if (response.getStatusCode() < 500) {
result.setErrorType(ErrorType.Client);
} else {
result.setErrorType(ErrorType.Service);
}
for (Entry<String, String> headerEntry : response.getHeaders().entrySet()) {
if (headerEntry.getKey().equalsIgnoreCase("X-Amzn-RequestId")) {
result.setRequestId(headerEntry.getValue());
}
}
return result;
}
代码示例来源:origin: com.amazonaws/dynamodb-streams-kinesis-adapter
/**
* After determining the transformation in the API specific transform method, this helper method sets the
* transformed exception's fields to match the original exception. If no transformation occurred, the original
* exception is returned.
*
* @param original The original DynamoDB Streams exception
* @param transformed The equivalent Kinesis exception that needs its fields updated
* @return The final result of the transformation ready to be thrown by the adapter
*/
private static AmazonServiceException applyFields(AmazonServiceException original, AmazonServiceException transformed) {
if (transformed == null) {
LOG.error("Could not transform a DynamoDB AmazonServiceException to a compatible Kinesis exception", original);
return original;
}
// Here we update the transformed exception fields with the original exception values
if (original.getErrorCode() != null) {
transformed.setErrorCode(original.getErrorCode());
}
// Null is transformed to UNKNOWN, so a null value is impossible.
transformed.setErrorType(original.getErrorType());
if (original.getRequestId() != null) {
transformed.setRequestId(original.getRequestId());
}
if (original.getServiceName() != null) {
transformed.setServiceName(original.getServiceName());
}
transformed.setStatusCode(original.getStatusCode());
LOG.error(String.format("DynamoDB Streams exception: %s tranformed to Kinesis %s", original.getClass(), transformed.getClass()), original);
return transformed;
}
代码示例来源:origin: com.gluonhq/aws-java-sdk-core
/**
* @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-android-sdk-core
@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: com.gluonhq/aws-java-sdk-core
@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: com.amazonaws/aws-android-sdk-core
/**
* @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: Nextdoor/bender
/**
* @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: Nextdoor/bender
@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;
}
内容来源于网络,如有侵权,请联系作者删除!