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 -4
View File
@@ -8,11 +8,10 @@ package model
import (
"encoding/binary"
"fmt"
"io"
"time"
"github.com/pkg/errors"
"github.com/syncthing/syncthing/lib/fs"
"github.com/syncthing/syncthing/lib/osutil"
"github.com/syncthing/syncthing/lib/protocol"
@@ -177,12 +176,12 @@ func (s *sharedPullerState) tempFileInWritableDir(_ string) error {
// what the umask dictates.
if err := s.fs.Chmod(s.tempName, mode); err != nil {
return errors.Wrap(err, "setting perms on temp file")
return fmt.Errorf("setting perms on temp file: %w", err)
}
}
fd, err := s.fs.OpenFile(s.tempName, flags, mode)
if err != nil {
return errors.Wrap(err, "opening temp file")
return fmt.Errorf("opening temp file: %w", err)
}
// Hide the temporary file