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
+4 -4
View File
@@ -8,14 +8,14 @@ package versioner
import (
"context"
"errors"
"fmt"
"path/filepath"
"regexp"
"sort"
"strings"
"time"
"github.com/pkg/errors"
"github.com/syncthing/syncthing/lib/config"
"github.com/syncthing/syncthing/lib/fs"
"github.com/syncthing/syncthing/lib/osutil"
@@ -200,11 +200,11 @@ func restoreFile(method fs.CopyRangeMethod, src, dst fs.Filesystem, filePath str
case info.IsSymlink():
// Remove existing symlinks (as we don't want to archive them)
if err := dst.Remove(filePath); err != nil {
return errors.Wrap(err, "removing existing symlink")
return fmt.Errorf("removing existing symlink: %w", err)
}
case info.IsRegular():
if err := archiveFile(method, dst, src, filePath, tagger); err != nil {
return errors.Wrap(err, "archiving existing file")
return fmt.Errorf("archiving existing file: %w", err)
}
default:
panic("bug: unknown item type")