Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
fix: Classify DNS errors as user (#1190)
Browse files Browse the repository at this point in the history
  • Loading branch information
irmatov authored Jul 20, 2022
1 parent 7395644 commit c509dae
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c509dae

Please sign in to comment.