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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user