cloud-nuke icon indicating copy to clipboard operation
cloud-nuke copied to clipboard

Improve error handling for common/known errors

Open marinalimeira opened this issue 2 years ago • 0 comments

The logic for error handling is the same in the nuke default Ingress/Egress SG:

if awsErr, isAwsErr := err.(awserr.Error); isAwsErr && awsErr.Code() == "InvalidPermission.NotFound" {
 logging.Logger.Debugf("Egress rule not present (ok)")
} else {
 return fmt.Errorf("error deleting ingress rule: %s", errors.WithStackTrace(err))
}

The pattern awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "xpto" is common through the codebase.

Originally posted by @denis256 in https://github.com/gruntwork-io/cloud-nuke/pull/401#discussion_r1087905689

marinalimeira avatar Jan 26 '23 14:01 marinalimeira