aws-sagemaker-modelexplainabilityjobdefinition/src/main/java/software/amazon/sagemaker/modelexplainabilityjobdefinition/Translator.java [21:58]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class Translator {

    /**
     * Throws Cfn exception corresponding to error code of the given exception.
     *
     * @param operation
     * @param e exception
     */
    public static void throwCfnException(final String operation, final AwsServiceException 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);
    }

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



aws-sagemaker-modelqualityjobdefinition/src/main/java/software/amazon/sagemaker/modelqualityjobdefinition/Translator.java [21:58]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class Translator {

    /**
     * Throws Cfn exception corresponding to error code of the given exception.
     *
     * @param operation
     * @param e exception
     */
    public static void throwCfnException(final String operation, final AwsServiceException 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);
    }

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



