use of software.amazon.awssdk.protocols.core.ExceptionMetadata in project aws-sdk-java-v2 by aws.
the class AwsJsonProtocolErrorUnmarshaller method unmarshall.
private AwsServiceException unmarshall(SdkHttpFullResponse response, ExecutionAttributes executionAttributes) {
JsonContent jsonContent = JsonContent.createJsonContent(response, jsonFactory);
String errorCode = errorCodeParser.parseErrorCode(response, jsonContent);
Optional<ExceptionMetadata> modeledExceptionMetadata = exceptions.stream().filter(e -> e.errorCode().equals(errorCode)).findAny();
SdkPojo sdkPojo = modeledExceptionMetadata.map(ExceptionMetadata::exceptionBuilderSupplier).orElse(defaultExceptionSupplier).get();
AwsServiceException.Builder exception = ((AwsServiceException) jsonProtocolUnmarshaller.unmarshall(sdkPojo, response, jsonContent.getJsonNode())).toBuilder();
String errorMessage = errorMessageParser.parseErrorMessage(response, jsonContent.getJsonNode());
exception.awsErrorDetails(extractAwsErrorDetails(response, executionAttributes, jsonContent, errorCode, errorMessage));
exception.clockSkew(getClockSkew(executionAttributes));
// Status code and request id are sdk level fields
exception.message(errorMessage);
exception.statusCode(statusCode(response, modeledExceptionMetadata));
exception.requestId(getRequestIdFromHeaders(response.headers()));
exception.extendedRequestId(getExtendedRequestIdFromHeaders(response.headers()));
return exception.build();
}
Aggregations