in aws-sagemaker-appimageconfig/src/main/java/software/amazon/sagemaker/appimageconfig/Translator.java [34:74]
static void throwCfnException(
final String operation,
final String resourceType,
final String resourceName,
final AwsServiceException e
) {
if (e instanceof ResourceInUseException) {
throw new ResourceAlreadyExistsException(resourceType, resourceName, e);
}
if (e instanceof ResourceNotFoundException) {
throw new CfnNotFoundException(resourceType, resourceName, e);
}
if (e instanceof ResourceLimitExceededException) {
throw new CfnServiceLimitExceededException(resourceType, e.getMessage(), e);
}
if(e.awsErrorDetails() != null && StringUtils.isNotBlank(e.awsErrorDetails().errorCode())) {
String errorMessage = e.awsErrorDetails().errorMessage();
switch (e.awsErrorDetails().errorCode()) {
case "UnauthorizedOperation":
throw new CfnAccessDeniedException(errorMessage, e);
case "InvalidParameter":
case "InvalidParameterValue":
case "ValidationError":
case "ValidationException":
throw new CfnInvalidRequestException(errorMessage, e);
case "InternalError":
case "ServiceUnavailable":
throw new CfnServiceInternalErrorException(errorMessage, e);
case "ThrottlingException":
throw new CfnThrottlingException(errorMessage, e);
default:
throw new CfnGeneralServiceException(errorMessage, e);
}
}
throw new CfnGeneralServiceException(operation, e);
}