diff options
author | Jakob Borg <jakob@kastelo.net> | 2020-03-03 22:40:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-03 22:40:00 +0100 |
commit | dd92b2b8f48d919326b4b8a36349610f17ac8c4e (patch) | |
tree | ea5d2a7837f80f6bcd1d6f31bcced015ae8c19fd /test | |
parent | eddc8d3ff220f03535c42627e618126882372daf (diff) | |
download | syncthing-dd92b2b8f48d919326b4b8a36349610f17ac8c4e.tar.gz syncthing-dd92b2b8f48d919326b4b8a36349610f17ac8c4e.zip |
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.
Diffstat (limited to 'test')
-rw-r--r-- | test/sync_test.go | 6 | ||||
-rw-r--r-- | test/util.go | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/test/sync_test.go b/test/sync_test.go index ad5d1388c..8fe558f36 100644 --- a/test/sync_test.go +++ b/test/sync_test.go @@ -265,7 +265,7 @@ func scSyncAndCompare(p []*rc.Process, expected [][]fileInfo) error { return err } if err := compareDirectoryContents(actual, expected[0]); err != nil { - return fmt.Errorf("%s: %v", dir, err) + return fmt.Errorf("%s: %w", dir, err) } } @@ -276,7 +276,7 @@ func scSyncAndCompare(p []*rc.Process, expected [][]fileInfo) error { return err } if err := compareDirectoryContents(actual, expected[1]); err != nil { - return fmt.Errorf("%s: %v", dir, err) + return fmt.Errorf("%s: %w", dir, err) } } } @@ -288,7 +288,7 @@ func scSyncAndCompare(p []*rc.Process, expected [][]fileInfo) error { return err } if err := compareDirectoryContents(actual, expected[2]); err != nil { - return fmt.Errorf("%s: %v", dir, err) + return fmt.Errorf("%s: %w", dir, err) } } } diff --git a/test/util.go b/test/util.go index 7e4d24287..b4dc601e1 100644 --- a/test/util.go +++ b/test/util.go @@ -330,7 +330,7 @@ func compareDirectories(dirs ...string) error { for i := 1; i < len(res); i++ { if res[i] != res[0] { close(abort) - return fmt.Errorf("Mismatch; %#v (%s) != %#v (%s)", res[i], dirs[i], res[0], dirs[0]) + return fmt.Errorf("mismatch; %#v (%s) != %#v (%s)", res[i], dirs[i], res[0], dirs[0]) } } @@ -381,7 +381,7 @@ func compareDirectoryContents(actual, expected []fileInfo) error { for i := range actual { if actual[i] != expected[i] { - return fmt.Errorf("Mismatch; actual %#v != expected %#v", actual[i], expected[i]) + return fmt.Errorf("mismatch; actual %#v != expected %#v", actual[i], expected[i]) } } return nil |