all: Modernize error wrapping (#8491)

This replaces old style errors.Wrap with modern fmt.Errorf and removes
the (direct) dependency on github.com/pkg/errors. A couple of cases are
adjusted by hand as previously errors.Wrap(nil, ...) would return nil,
which is not what fmt.Errorf does.
This commit is contained in:
Jakob Borg
2022-08-16 10:01:49 +02:00
committed by GitHub
parent 75eeae0ee7
commit b10d106a55
23 changed files with 108 additions and 109 deletions
+3 -3
View File
@@ -8,6 +8,7 @@ package model
import (
"context"
"errors"
"fmt"
"math/rand"
"path/filepath"
@@ -15,8 +16,6 @@ import (
"sync/atomic"
"time"
"github.com/pkg/errors"
"github.com/syncthing/syncthing/lib/config"
"github.com/syncthing/syncthing/lib/db"
"github.com/syncthing/syncthing/lib/events"
@@ -317,7 +316,7 @@ func (f *folder) getHealthErrorAndLoadIgnores() error {
}
if f.Type != config.FolderTypeReceiveEncrypted {
if err := f.ignores.Load(".stignore"); err != nil && !fs.IsNotExist(err) {
return errors.Wrap(err, "loading ignores")
return fmt.Errorf("loading ignores: %w", err)
}
}
return nil
@@ -1060,6 +1059,7 @@ func (f *folder) monitorWatch(ctx context.Context) {
l.Warnf("Filesystem watching (kqueue) is enabled on %v with a lot of files/directories, and that requires a lot of resources and might slow down your system significantly", f.Description())
}
case <-ctx.Done():
aggrCancel() // for good measure and keeping the linters happy
return
}
}