File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-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.
1215func HandleExitError (err error ) {
1316 if err == nil {
1417 return
1518 }
1619
17- var exitErr * exec.ExitError
18- if errors .As (err , & exitErr ) {
20+ // Do not use errors.As, because we want to match only *exec.ExitError, not wrapped ones.
21+ // https://github.com/lima-vm/lima/pull/4168
22+ if exitErr , ok := err .(* exec.ExitError ); ok {
1923 os .Exit (exitErr .ExitCode ()) //nolint:revive // it's intentional to call os.Exit in this function
2024 return
2125 }
You can’t perform that action at this time.
0 commit comments