in aws-ssm-maintenancewindowtask/src/main/java/software/amazon/ssm/maintenancewindowtask/translator/ExceptionTranslator.java [34:67]
public BaseHandlerException translateFromServiceException(final Exception serviceException,
final SsmRequest request,
final ResourceModel desiredResourceModel) {
if (serviceException instanceof AlreadyExistsException) {
return new CfnAlreadyExistsException(ResourceModel.TYPE_NAME,
desiredResourceModel.getWindowTaskId(),
serviceException);
} else if (serviceException instanceof ResourceLimitExceededException) {
return new CfnServiceLimitExceededException(ResourceModel.TYPE_NAME,
serviceException.getMessage(),
serviceException);
} else if (serviceException instanceof DoesNotExistException) {
return new CfnNotFoundException(ResourceModel.TYPE_NAME,
desiredResourceModel.getWindowTaskId(),
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(serviceException.getMessage(), 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);
}
}