mirror of
https://blitiri.com.ar/repos/chasquid
synced 2026-10-28 15:02:28 +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:
@@ -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))}
|
||||
|
||||
Reference in New Issue
Block a user