mirror of
https://github.com/syncthing/syncthing.git
synced 2025-12-23 22:18:14 -05:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user