in aws-sagemaker-modelpackagegroup/src/main/java/software/amazon/sagemaker/modelpackagegroup/ExceptionMapper.java [21:49]
static void throwCfnException(final String operation, final AwsServiceException e) {
// The exception thrown due to validation failure does not have error code set,
// hence we need to check it using error message
if(StringUtils.isNotBlank(e.getMessage()) && e.getMessage().contains("validation error detected")) {
throw new CfnInvalidRequestException(operation, e);
}
if(e.awsErrorDetails() != null && StringUtils.isNotBlank(e.awsErrorDetails().errorCode())) {
switch (e.awsErrorDetails().errorCode()) {
case "UnauthorizedOperation":
throw new CfnAccessDeniedException(operation, e);
case "InvalidParameter":
case "InvalidParameterValue":
case "ValidationError":
throw new CfnInvalidRequestException(operation, e);
case "InternalError":
case "ServiceUnavailable":
throw new CfnServiceInternalErrorException(operation, e);
case "ResourceLimitExceeded":
throw new CfnServiceLimitExceededException(e);
case "ResourceNotFound":
throw new CfnNotFoundException(e);
case "ThrottlingException":
throw new CfnThrottlingException(operation, e);
default:
throw new CfnGeneralServiceException(operation, e);
}
}
throw new CfnGeneralServiceException(operation, e);
}