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
2024-02-26 11:19:38 +00:00
parent 581c16d72f
commit cd566eb097
103 changed files with 426 additions and 390 deletions

View File

@@ -1212,7 +1212,7 @@ func DecodeFailure(r io.Reader, pver uint32) (FailureMessage, error) {
// is a 2 byte length followed by the payload itself.
var failureLength uint16
if err := ReadElement(r, &failureLength); err != nil {
return nil, fmt.Errorf("unable to read error len: %v", err)
return nil, fmt.Errorf("unable to read error len: %w", err)
}
if failureLength > FailureMessageLength {
return nil, fmt.Errorf("failure message is too "+
@@ -1236,7 +1236,7 @@ func DecodeFailureMessage(r io.Reader, pver uint32) (FailureMessage, error) {
// the first two bytes of the buffer.
var codeBytes [2]byte
if _, err := io.ReadFull(r, codeBytes[:]); err != nil {
return nil, fmt.Errorf("unable to read failure code: %v", err)
return nil, fmt.Errorf("unable to read failure code: %w", err)
}
failCode := FailCode(binary.BigEndian.Uint16(codeBytes[:]))
@@ -1244,7 +1244,7 @@ func DecodeFailureMessage(r io.Reader, pver uint32) (FailureMessage, error) {
// additional data if needed.
failure, err := makeEmptyOnionError(failCode)
if err != nil {
return nil, fmt.Errorf("unable to make empty error: %v", err)
return nil, fmt.Errorf("unable to make empty error: %w", err)
}
// Finally, if this failure has a payload, then we'll read that now as

View File

@@ -223,7 +223,8 @@ func decodeShortChanIDs(r io.Reader) (ShortChanIDEncoding, []ShortChannelID, err
N: maxZlibBufSize,
})
if err != nil {
return 0, nil, fmt.Errorf("unable to create zlib reader: %v", err)
return 0, nil, fmt.Errorf("unable to create zlib "+
"reader: %w", err)
}
var (