aws-sagemaker-featuregroup/src/main/java/software/amazon/sagemaker/featuregroup/Translator.java [25:77]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class Translator {

    /**
     * Throws Cfn exception corresponding to error code of the given exception.
     *
     * @param operation operation
     * @param resourceType resource type
     * @param resourceName resource name
     * @param e exception
     */
    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 "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);
    }

    static <T> Stream<T> streamOfOrEmpty(final Collection<T> collection) {
        return Optional.ofNullable(collection)
                .map(Collection::stream)
                .orElseGet(Stream::empty);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



aws-sagemaker-pipeline/src/main/java/software/amazon/sagemaker/pipeline/Translator.java [25:77]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class Translator {

    /**
     * Throws Cfn exception corresponding to error code of the given exception.
     *
     * @param operation operation
     * @param resourceType resource type
     * @param resourceName resource name
     * @param e exception
     */
    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 "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);
    }

    static <T> Stream<T> streamOfOrEmpty(final Collection<T> collection) {
        return Optional.ofNullable(collection)
                .map(Collection::stream)
                .orElseGet(Stream::empty);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



