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

+2 -2
View File
@@ -307,7 +307,7 @@ func createTestCircuit(ks htlcswitch.Keystone, cm htlcswitch.CircuitMap) error {
// should succeed.
_, err := cm.CommitCircuits(circuit)
if err != nil {
return fmt.Errorf("failed to commit circuits: %v", err)
return fmt.Errorf("failed to commit circuits: %w", err)
}
// If the keystone has no outgoing key, we won't open it.
@@ -318,7 +318,7 @@ func createTestCircuit(ks htlcswitch.Keystone, cm htlcswitch.CircuitMap) error {
// Open the circuit, implicitly creates a keystone on disk.
err = cm.OpenCircuits(ks)
if err != nil {
return fmt.Errorf("failed to open circuits: %v", err)
return fmt.Errorf("failed to open circuits: %w", err)
}
return nil
+1 -1
View File
@@ -63,7 +63,7 @@ func NewBoltBackendCreator(dbPath,
db, err := kvdb.GetBoltBackend(cfg)
if err != nil {
return nil, fmt.Errorf("could not open boltdb: %v", err)
return nil, fmt.Errorf("could not open boltdb: %w", err)
}
return db, nil
+1 -1
View File
@@ -686,7 +686,7 @@ func (f *interceptedForward) FailWithCode(code lnwire.FailCode) error {
// of the failure.
reason, err := f.packet.obfuscator.EncryptFirstHop(failureMsg)
if err != nil {
return fmt.Errorf("failed to encrypt failure reason %v", err)
return fmt.Errorf("failed to encrypt failure reason %w", err)
}
return f.resolve(&lnwire.UpdateFailHTLC{
+1 -1
View File
@@ -3545,7 +3545,7 @@ func (l *channelLink) settleHTLC(preimage lntypes.Preimage,
preimage, pd.HtlcIndex, pd.SourceRef, nil, nil,
)
if err != nil {
return fmt.Errorf("unable to settle htlc: %v", err)
return fmt.Errorf("unable to settle htlc: %w", err)
}
// If the link is in hodl.BogusSettle mode, replace the preimage with a
+4 -3
View File
@@ -497,7 +497,7 @@ func (s *Switch) GetAttemptResult(attemptID uint64, paymentHash lntypes.Hash,
deobfuscator, n, attemptID, paymentHash,
)
if err != nil {
e := fmt.Errorf("unable to extract result: %v", err)
e := fmt.Errorf("unable to extract result: %w", err)
log.Error(e)
resultChan <- &PaymentResult{
Error: e,
@@ -709,7 +709,8 @@ func (s *Switch) ForwardPackets(linkQuit chan struct{},
default:
err := s.routeAsync(packet, fwdChan, linkQuit)
if err != nil {
return fmt.Errorf("failed to forward packet %v", err)
return fmt.Errorf("failed to forward packet %w",
err)
}
numSent++
}
@@ -754,7 +755,7 @@ func (s *Switch) ForwardPackets(linkQuit chan struct{},
for _, packet := range addedPackets {
err := s.routeAsync(packet, fwdChan, linkQuit)
if err != nil {
return fmt.Errorf("failed to forward packet %v", err)
return fmt.Errorf("failed to forward packet %w", err)
}
numSent++
}
+1 -1
View File
@@ -1173,7 +1173,7 @@ func (h *hopNetwork) createChannelLink(server, peer *mockServer,
channel,
)
if err := server.htlcSwitch.AddLink(link); err != nil {
return nil, fmt.Errorf("unable to add channel link: %v", err)
return nil, fmt.Errorf("unable to add channel link: %w", err)
}
go func() {