*: fmt.Errorf: use %w when appropriate

This should result in no change when the error is printed, but make the
errors returned unwrappable, meaning errors.As and errors.Is will work.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2021-06-08 20:05:54 -07:00
parent d8ba4128b2
commit 7be93a66b9
20 changed files with 50 additions and 49 deletions
+2 -2
View File
@@ -68,7 +68,7 @@ var psCommand = cli.Command{
cmd := exec.Command("ps", psArgs...)
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("%s: %s", err, output)
return fmt.Errorf("%w: %s", err, output)
}
lines := strings.Split(string(output), "\n")
@@ -85,7 +85,7 @@ var psCommand = cli.Command{
fields := strings.Fields(line)
p, err := strconv.Atoi(fields[pidIndex])
if err != nil {
return fmt.Errorf("unexpected pid '%s': %s", fields[pidIndex], err)
return fmt.Errorf("unable to parse pid: %w", err)
}
for _, pid := range pids {