always wrap errors when creating new ones with fmt.Errorf()

It doesn't really change anything in most of the cases, but it's a useful
habit anyway.

Fix #350.
This commit is contained in:
Roman Khimov 2020-08-06 19:09:57 +03:00
parent 205f52c563
commit 0e2784cd2c
24 changed files with 105 additions and 84 deletions

View file

@ -55,11 +55,11 @@ func (d dump) normalize() {
func compare(a, b string) error {
dumpA, err := readFile(a)
if err != nil {
return fmt.Errorf("reading file %s: %v", a, err)
return fmt.Errorf("reading file %s: %w", a, err)
}
dumpB, err := readFile(b)
if err != nil {
return fmt.Errorf("reading file %s: %v", b, err)
return fmt.Errorf("reading file %s: %w", b, err)
}
dumpA.normalize()
dumpB.normalize()
@ -143,7 +143,7 @@ func cliMain(c *cli.Context) error {
bname := filepath.Join(b, fname)
err := compare(aname, bname)
if err != nil {
return fmt.Errorf("file %s: %v", fname, err)
return fmt.Errorf("file %s: %w", fname, err)
}
}
}