Archived
Merge pull request #37 from beatz174-bit/codex/fix-dynu-dns-record-update-error
Refine 404 diagnostic labeling for Dynu API errors
This commit is contained in:
@@ -2,6 +2,7 @@ package provider
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/dynu/terraform-provider-dynu/internal/dynuclient"
|
||||
)
|
||||
@@ -16,7 +17,11 @@ func diagnosticSummary(defaultSummary string, err error) string {
|
||||
case 401, 403:
|
||||
return defaultSummary + " (authentication failed)"
|
||||
case 404:
|
||||
return defaultSummary + " (not found)"
|
||||
normalizedType := strings.ToLower(strings.TrimSpace(apiErr.Type))
|
||||
if strings.Contains(normalizedType, "not found") {
|
||||
return defaultSummary + " (not found)"
|
||||
}
|
||||
return defaultSummary
|
||||
default:
|
||||
return defaultSummary
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ func TestDiagnosticSummary(t *testing.T) {
|
||||
{name: "non api error", err: os.ErrNotExist, summary: "Unable to list Dynu domains", want: "Unable to list Dynu domains"},
|
||||
{name: "auth error", err: &dynuclient.APIError{StatusCode: 401, Type: "Unauthorized", Message: "invalid"}, summary: "Unable to list Dynu domains", want: "Unable to list Dynu domains (authentication failed)"},
|
||||
{name: "not found", err: &dynuclient.APIError{StatusCode: 404, Type: "Not Found", Message: "missing"}, summary: "Unable to resolve Dynu domain from hostname", want: "Unable to resolve Dynu domain from hostname (not found)"},
|
||||
{name: "404 validation exception", err: &dynuclient.APIError{StatusCode: 404, Type: "Request Exception", Message: "Invalid."}, summary: "Unable to update Dynu DNS record", want: "Unable to update Dynu DNS record"},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
|
||||
Reference in New Issue
Block a user