netlink icon indicating copy to clipboard operation
netlink copied to clipboard

routeSubscribeAt should wrap the error it returns

Open maxatome opened this issue 1 year ago • 0 comments

routeSubscribeAt returns 3 kinds of errors. 2 of them are encapsulated with fmt.Errorf.

  • https://github.com/vishvananda/netlink/blob/main/route_linux.go#L1664
  • https://github.com/vishvananda/netlink/blob/main/route_linux.go#L1685

To facilitate the caller life it could be cool to use %w verb instead of %v in fmt.Errorf call.

This way the caller can, for example, easily check for ENOBUFS error:

if errors.Is(err, syscall.ENOBUFS) {

but this needs go1.13.

As this repo requires 1.12, this means we have to change this requirement to 1.13 (to avoid doing horrible things with build tags, as go1.12 is now more than 3 years old and no longer maintained by the go team.)

Is this change a no-go or do you accept a PR?

Note that v1.1.0 does not encapsulate routeSubscribeAt error with fmt.Errorf, so errors.Is(err, syscall.ENOBUFS) works fine.

maxatome avatar Oct 11 '23 16:10 maxatome