public BaseHandlerException translateFromServiceException()

in aws-ssm-maintenancewindow/src/main/java/software/amazon/ssm/maintenancewindow/translator/ExceptionTranslator.java [32:59]


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

        if (serviceException instanceof AlreadyExistsException) {

            return new CfnAlreadyExistsException(serviceException);
        } else if (serviceException instanceof ResourceLimitExceededException) {

            return new CfnServiceLimitExceededException(serviceException);
        } else if (serviceException instanceof DoesNotExistException) {

            return new CfnNotFoundException(serviceException);
        } else if (serviceException instanceof InternalServerErrorException) {

            return new CfnServiceInternalErrorException(
                    getClassNameWithoutRequestSuffix(request.getClass().getSimpleName()),
                    serviceException);
        } else if (serviceException instanceof FeatureNotAvailableException
                || serviceException instanceof TargetInUseException
                || serviceException instanceof IdempotentParameterMismatchException) {

            return new CfnInvalidRequestException(request.toString(), 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);
        }
    }