Fix error handling for extension and shell alias commands (#7567)

This commit is contained in:
Sam Coe 2023-06-20 08:41:02 +09:00 committed by GitHub
parent 8587851202
commit 9be9dc22e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View file

@ -109,7 +109,7 @@ func mainRun() exitCode {
if cmd, err := rootCmd.ExecuteContextC(ctx); err != nil {
var pagerPipeError *iostreams.ErrClosedPagerPipe
var noResultsError cmdutil.NoResultsError
var execError *exec.ExitError
var extError *root.ExternalCommandExitError
var authError *root.AuthError
if err == cmdutil.SilentError {
return exitError
@ -130,8 +130,9 @@ func mainRun() exitCode {
}
// no results is not a command failure
return exitOK
} else if errors.As(err, &execError) {
return exitCode(execError.ExitCode())
} else if errors.As(err, &extError) {
// pass on exit codes from extensions and shell aliases
return exitCode(extError.ExitCode())
}
printError(stderr, err, cmd, hasDebug)