public BaseHandlerException translateFromServiceException()

in aws-ssm-association/src/main/java/com/amazonaws/ssm/association/translator/ExceptionTranslator.java [42:87]


    public BaseHandlerException translateFromServiceException(final Exception serviceException,
                                                              final SsmRequest request,
                                                              final ResourceModel desiredResourceModel) {

        if (serviceException instanceof AssociationAlreadyExistsException) {

            return new CfnAlreadyExistsException(ResourceModel.TYPE_NAME,
                getResourceModelIdentifier(desiredResourceModel),
                serviceException);
        } else if (serviceException instanceof AssociationLimitExceededException
            || serviceException instanceof AssociationVersionLimitExceededException) {

            return new CfnServiceLimitExceededException(ResourceModel.TYPE_NAME,
                serviceException.getMessage(),
                serviceException);
        } else if (serviceException instanceof AssociationDoesNotExistException) {

            return new CfnNotFoundException(ResourceModel.TYPE_NAME,
                getResourceModelIdentifier(desiredResourceModel),
                serviceException);
        } else if (serviceException instanceof InternalServerErrorException) {

            return new CfnServiceInternalErrorException(
                getClassNameWithoutRequestSuffix(request.getClass().getSimpleName()),
                serviceException);
        } else if (serviceException instanceof InvalidAssociationVersionException
            || serviceException instanceof InvalidDocumentException
            || serviceException instanceof InvalidDocumentVersionException
            || serviceException instanceof InvalidInstanceIdException
            || serviceException instanceof InvalidOutputLocationException
            || serviceException instanceof InvalidParametersException
            || serviceException instanceof InvalidScheduleException
            || serviceException instanceof InvalidTargetException
            || serviceException instanceof UnsupportedPlatformTypeException) {

            return new CfnInvalidRequestException(serviceException.getMessage(), serviceException);
        } else if (serviceException instanceof TooManyUpdatesException) {

            return new CfnThrottlingException(getClassNameWithoutRequestSuffix(request.getClass().getSimpleName()),
                serviceException);
        } else {
            // in case of unknown/unexpected service exceptions, use a generic exception with the name of the failed operation
            return new CfnGeneralServiceException(getClassNameWithoutRequestSuffix(request.getClass().getSimpleName()),
                serviceException);
        }
    }