diff --git a/agent/config/builder.go b/agent/config/builder.go index 7269da4cd..8bfde347a 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 4d6945aab..48601eafe 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 7affa75b8..c7f3c78c7 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) } }