From 4be867c560aeb24d3763ddb5b28a241db0d66af4 Mon Sep 17 00:00:00 2001 From: greatroar <61184462+greatroar@users.noreply.github.com> Date: Sat, 26 Mar 2022 11:05:57 +0100 Subject: [PATCH] all: Replace errors.Cause with errors.Is (#8236) --- lib/connections/service.go | 2 +- lib/model/folder_sendrecv.go | 2 +- lib/pmp/pmp.go | 6 +++--- lib/upnp/upnp.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/connections/service.go b/lib/connections/service.go index 24a6f1420..9cff1970e 100644 --- a/lib/connections/service.go +++ b/lib/connections/service.go @@ -882,7 +882,7 @@ func (s *connectionStatusHandler) ConnectionStatus() map[string]ConnectionStatus } func (s *connectionStatusHandler) setConnectionStatus(address string, err error) { - if errors.Cause(err) == context.Canceled { + if errors.Is(err, context.Canceled) { return } diff --git a/lib/model/folder_sendrecv.go b/lib/model/folder_sendrecv.go index 757e4504d..af57b7b0f 100644 --- a/lib/model/folder_sendrecv.go +++ b/lib/model/folder_sendrecv.go @@ -1849,7 +1849,7 @@ func (f *sendReceiveFolder) moveForConflict(name, lastModBy string, scanChan cha } func (f *sendReceiveFolder) newPullError(path string, err error) { - if errors.Cause(err) == f.ctx.Err() { + if errors.Is(err, f.ctx.Err()) { // Error because the folder stopped - no point logging/tracking return } diff --git a/lib/pmp/pmp.go b/lib/pmp/pmp.go index 7af5021d4..7530eb046 100644 --- a/lib/pmp/pmp.go +++ b/lib/pmp/pmp.go @@ -8,14 +8,14 @@ package pmp import ( "context" + "errors" "fmt" "net" "strings" "time" "github.com/jackpal/gateway" - "github.com/jackpal/go-nat-pmp" - "github.com/pkg/errors" + natpmp "github.com/jackpal/go-nat-pmp" "github.com/syncthing/syncthing/lib/nat" "github.com/syncthing/syncthing/lib/util" @@ -50,7 +50,7 @@ func Discover(ctx context.Context, renewal, timeout time.Duration) []nat.Device return ierr }) if err != nil { - if errors.Cause(err) == context.Canceled { + if errors.Is(err, context.Canceled) { return nil } if strings.Contains(err.Error(), "Timed out") { diff --git a/lib/upnp/upnp.go b/lib/upnp/upnp.go index 9cf3b5afb..f88f0f2c7 100644 --- a/lib/upnp/upnp.go +++ b/lib/upnp/upnp.go @@ -212,7 +212,7 @@ loop: case *UnsupportedDeviceTypeError: l.Debugln(err.Error()) default: - if errors.Cause(err) != context.Canceled { + if !errors.Is(err, context.Canceled) { l.Infoln("UPnP parse:", err) } }