mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
*: 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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user