multi: fix fmt.Errorf error wrapping

Refactor fmt.Errorf usage to correctly wrap errors instead of using
non-wrapping format verbs.
This commit is contained in:
ffranr committed 2024-02-27 11:13:40 +00:00
1 parent 581c16d72f
commit cd566eb097
103 files changed
+426 -390

No files matched your search

+5 -5
View File
@@ -327,7 +327,7 @@ func (hn *HarnessNode) ConnectRPCWithMacaroon(mac *macaroon.Macaroon) (
return err
}, wait.DefaultTimeout)
if err != nil {
return nil, fmt.Errorf("error reading TLS cert: %v", err)
return nil, fmt.Errorf("error reading TLS cert: %w", err)
}
opts := []grpc.DialOption{
@@ -343,7 +343,7 @@ func (hn *HarnessNode) ConnectRPCWithMacaroon(mac *macaroon.Macaroon) (
}
macCred, err := macaroons.NewMacaroonCredential(mac)
if err != nil {
return nil, fmt.Errorf("error cloning mac: %v", err)
return nil, fmt.Errorf("error cloning mac: %w", err)
}
opts = append(opts, grpc.WithPerRPCCredentials(macCred))
@@ -452,7 +452,7 @@ func (hn *HarnessNode) Start(ctxt context.Context) error {
// Wait till the server is starting.
if err := hn.WaitUntilStarted(); err != nil {
return fmt.Errorf("waiting for start got: %v", err)
return fmt.Errorf("waiting for start got: %w", err)
}
// Subscribe for topology updates.
@@ -544,7 +544,7 @@ func (hn *HarnessNode) waitTillServerState(
case <-time.After(wait.NodeStartTimeout):
return fmt.Errorf("timeout waiting for server state")
case err := <-errChan:
return fmt.Errorf("receive server state err: %v", err)
return fmt.Errorf("receive server state err: %w", err)
case <-done:
return nil
@@ -906,7 +906,7 @@ func executePgQuery(query string) error {
postgresDatabaseDsn("postgres"),
)
if err != nil {
return fmt.Errorf("unable to connect to database: %v", err)
return fmt.Errorf("unable to connect to database: %w", err)
}
defer pool.Close()
+2 -2
View File
@@ -245,7 +245,7 @@ func (nw *nodeWatcher) WaitForChannelPolicyUpdate(
case <-timer:
expected, err := json.MarshalIndent(policy, "", "\t")
if err != nil {
return fmt.Errorf("encode policy err: %v", err)
return fmt.Errorf("encode policy err: %w", err)
}
policies, err := syncMapToJSON(
&nw.state.policyUpdates.Map,
@@ -274,7 +274,7 @@ func syncMapToJSON(state *sync.Map) ([]byte, error) {
})
policies, err := json.MarshalIndent(m, "", "\t")
if err != nil {
return nil, fmt.Errorf("encode polices err: %v", err)
return nil, fmt.Errorf("encode polices err: %w", err)
}
return policies, nil