File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 44package osutil
55
66import (
7- "errors"
87 "os"
98 "os/exec"
109)
1110
11+ // HandleExitError calls os.Exit immediately without printing an error, only if the error is an *exec.ExitError (non-nil).
12+ //
13+ // The function does not call os.Exit if the error is of any other type, even if it wraps an *exec.ExitError,
14+ // so that the caller can print the error message.
15+ // (i.e., fmt.Errorf("...: %w", &exec.ExitError{}))
1216func HandleExitError (err error ) {
1317 if err == nil {
1418 return
1519 }
1620
17- var exitErr * exec.ExitError
18- if errors .As (err , & exitErr ) {
21+ // Do not use errors.As, because we want to match only *exec.ExitError, not wrapped ones.
22+ // https://github.com/lima-vm/lima/pull/4168
23+ if exitErr , ok := err .(* exec.ExitError ); ok {
1924 os .Exit (exitErr .ExitCode ()) //nolint:revive // it's intentional to call os.Exit in this function
2025 return
2126 }
You can’t perform that action at this time.
0 commit comments