all: Tweak error creation (#6391)

- In the few places where we wrap errors, use the new Go 1.13 "%w"
  construction instead of %s or %v.

- Where we create errors with constant strings, consistently use
  errors.New and not fmt.Errorf.

- Remove capitalization from errors in the few places where we had that.
This commit is contained in:
Jakob Borg
2020-03-03 22:40:00 +01:00
committed by GitHub
parent eddc8d3ff2
commit dd92b2b8f4
30 changed files with 67 additions and 60 deletions
+5 -4
View File
@@ -7,7 +7,6 @@
package versioner
import (
"fmt"
"path/filepath"
"regexp"
"sort"
@@ -20,9 +19,11 @@ import (
"github.com/syncthing/syncthing/lib/util"
)
var errDirectory = fmt.Errorf("cannot restore on top of a directory")
var errNotFound = fmt.Errorf("version not found")
var errFileAlreadyExists = fmt.Errorf("file already exists")
var (
errDirectory = errors.New("cannot restore on top of a directory")
errNotFound = errors.New("version not found")
errFileAlreadyExists = errors.New("file already exists")
)
// TagFilename inserts ~tag just before the extension of the filename.
func TagFilename(name, tag string) string {
+2 -1
View File
@@ -9,6 +9,7 @@
package versioner
import (
"errors"
"fmt"
"time"
@@ -32,7 +33,7 @@ type factory func(filesystem fs.Filesystem, params map[string]string) Versioner
var factories = make(map[string]factory)
var ErrRestorationNotSupported = fmt.Errorf("version restoration not supported with the current versioner")
var ErrRestorationNotSupported = errors.New("version restoration not supported with the current versioner")
const (
TimeFormat = "20060102-150405"