From e18f3c1f6d34d5ed66b49eb1fb31bad4ef861df1 Mon Sep 17 00:00:00 2001 From: Freddy Date: Tue, 14 Sep 2021 11:08:06 -0600 Subject: [PATCH] Update error texts (#11022) Co-authored-by: Daniel Nephin --- agent/config/builder.go | 2 +- agent/structs/config_entry_gateways.go | 4 ++-- sdk/testutil/assertions.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/agent/config/builder.go b/agent/config/builder.go index 7269da4cd4..8bfde347a6 100644 --- a/agent/config/builder.go +++ b/agent/config/builder.go @@ -787,7 +787,7 @@ func (b *builder) build() (rt RuntimeConfig, err error) { return RuntimeConfig{}, fmt.Errorf("config_entries.bootstrap[%d]: %s", i, err) } if err := entry.Validate(); err != nil { - return RuntimeConfig{}, fmt.Errorf("config_entries.bootstrap[%d]: %s", i, err) + return RuntimeConfig{}, fmt.Errorf("config_entries.bootstrap[%d]: %w", i, err) } configEntries = append(configEntries, entry) } diff --git a/agent/structs/config_entry_gateways.go b/agent/structs/config_entry_gateways.go index 4d6945aab5..48601eafe8 100644 --- a/agent/structs/config_entry_gateways.go +++ b/agent/structs/config_entry_gateways.go @@ -171,7 +171,7 @@ func (e *IngressGatewayConfigEntry) Validate() error { serviceNames := make(map[ServiceID]struct{}) for i, s := range listener.Services { if err := validateInnerEnterpriseMeta(&s.EnterpriseMeta, &e.EnterpriseMeta); err != nil { - return fmt.Errorf("Services[%d].%v", i, err) + return fmt.Errorf("services[%d]: %w", i, err) } sn := NewServiceName(s.Name, &s.EnterpriseMeta) if err := s.RequestHeaders.Validate(listener.Protocol); err != nil { @@ -401,7 +401,7 @@ func (e *TerminatingGatewayConfigEntry) Validate() error { cid := NewServiceID(svc.Name, &svc.EnterpriseMeta) if err := validateInnerEnterpriseMeta(&svc.EnterpriseMeta, &e.EnterpriseMeta); err != nil { - return fmt.Errorf("Service %q: %v", cid.String(), err) + return fmt.Errorf("service %q: %w", cid, err) } // Check for duplicates within the entry diff --git a/sdk/testutil/assertions.go b/sdk/testutil/assertions.go index 7affa75b8d..c7f3c78c7d 100644 --- a/sdk/testutil/assertions.go +++ b/sdk/testutil/assertions.go @@ -14,6 +14,6 @@ func RequireErrorContains(t testing.TB, err error, expectedErrorMessage string) t.Fatal("An error is expected but got nil.") } if !strings.Contains(err.Error(), expectedErrorMessage) { - t.Fatalf("unexpected error: %v", err) + t.Fatalf("expected err %v to contain %q", err, expectedErrorMessage) } }