/// <summary> /// Not all exceptions are bad. Some just mean there is nothing to do, which is fine. /// This method will ignore expected exceptions, and rethrow any that are really issues. /// </summary> /// <param name="ex">The exception we need to deal with</param> /// <exception cref="AmazonCloudFormationException">The supplied exception if it really is an error</exception> private bool DealWithUpdateException(AmazonCloudFormationException ex) { Guard.NotNull(ex, "ex can not be null"); // Unfortunately there are no better fields in the exception to use to determine the // kind of error than the message. We are forced to match message strings. if (ex.Message.Contains("No updates are to be performed")) { Log.Info("No updates are to be performed"); return(true); } if (ex.ErrorCode == "AccessDenied") { throw new PermissionException( "AWS-CLOUDFORMATION-ERROR-0011: The AWS account used to perform the operation does not have " + "the required permissions to update the stack.\n" + ex.Message + "\n" + "For more information visit https://g.octopushq.com/AwsCloudFormationDeploy#aws-cloudformation-error-0011"); } throw new UnknownException( "AWS-CLOUDFORMATION-ERROR-0011: An unrecognised exception was thrown while updating a CloudFormation stack.\n" + "For more information visit https://g.octopushq.com/AwsCloudFormationDeploy#aws-cloudformation-error-0011", ex); }
/// <summary> /// Not all exceptions are bad. Some just mean there is nothing to do, which is fine. /// This method will ignore expected exceptions, and rethrow any that are really issues. /// </summary> /// <param name="ex">The exception we need to deal with</param> /// <exception cref="AmazonCloudFormationException">The supplied exception if it really is an error</exception> private bool DealWithUpdateException(AmazonCloudFormationException ex) { Guard.NotNull(ex, "ex can not be null"); // Unfortunately there are no better fields in the exception to use to determine the // kind of error than the message. We are forced to match message strings. if (ex.Message.Contains("No updates are to be performed")) { Log.Info("No updates are to be performed"); return(true); } if (ex.ErrorCode == "AccessDenied") { throw new PermissionException( "The AWS account used to perform the operation does not have the required permissions to update the stack.\n" + "Please ensure the current account has permission to perfrom action 'cloudformation:UpdateStack'.\n" + ex.Message); } throw new UnknownException("An unrecognised exception was thrown while updating a CloudFormation stack.\n", ex); }