1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2026-10-29 15:02:30 +00:00

Wrap errors with %w when returning them

Many places where we return errors don't use the %w wrapping, because
they predate that functionality.

This patch changes those to use %w, so callers can inspect the
underlying errors with errors.Is and errors.As if needed in the future.

The text of the errors does not change, and no existing callers inspect
these errors, so there are no behaviour changes.
This commit is contained in:
Alberto Bertogli
2026-10-03 11:03:49 +01:00
parent 8b19760f4e
commit bfb9694f0c
9 changed files with 27 additions and 27 deletions
+2 -2
View File
@@ -181,7 +181,7 @@ func readTCPMessage(conn net.Conn) (*dnsmessage.Message, error) {
msg := &dnsmessage.Message{}
err = msg.Unpack(data)
if err != nil {
return nil, fmt.Errorf("%v error unpacking message: %v", addr, err)
return nil, fmt.Errorf("%v error unpacking message: %w", addr, err)
}
return msg, nil
@@ -190,7 +190,7 @@ func readTCPMessage(conn net.Conn) (*dnsmessage.Message, error) {
func writeTCPMessage(conn net.Conn, msg *dnsmessage.Message) error {
rbuf, err := msg.Pack()
if err != nil {
return fmt.Errorf("error packing reply: %v", err)
return fmt.Errorf("error packing reply: %w", err)
}
lenHdr := struct{ Len uint16 }{Len: uint16(len(rbuf))}