diff --git a/client/errors.go b/client/errors.go index b916778e0..d07b58546 100644 --- a/client/errors.go +++ b/client/errors.go @@ -44,6 +44,7 @@ var ( resourceNotExistsRegex = regexp.MustCompile(`(\sThe )([A-Za-z0-9 -]+ )'([A-Za-z0-9-]+?)'( does not exist)`) resourceNotFoundRegex = regexp.MustCompile(`([A-Za-z0-9 -]+)( name not found - Could not find )([A-Za-z0-9 -]+)( named )'([A-Za-z0-9-]+?)'`) autoscalingGroupNotFound = regexp.MustCompile(`(ValidationError: Group ).+( not found)`) + dnsErrorRegex = regexp.MustCompile(`dial (?:tcp|udp): lookup .* on .*: [^:]+$`) ) var errorCodeDescriptions = map[string]string{ @@ -185,6 +186,19 @@ func classifyError(err error, fallbackType diag.Type, accounts []string, opts .. ), } } + if dnsErrorRegex.MatchString(err.Error()) { + return diag.Diagnostics{ + RedactError(accounts, diag.NewBaseError(err, + diag.USER, + append(opts, + diag.WithType(diag.USER), + diag.WithSeverity(diag.ERROR), + ParseSummaryMessage(err), + diag.WithDetails("Encountered a DNS error. Please check your DNS and networking settings and try again."), + )...), + ), + } + } // Take over from SDK and always return diagnostics, redacting PII if d, ok := err.(diag.Diagnostic); ok {