Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions errorutil/errorutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
package errorutil

import (
"errors"
"os/exec"
"regexp"
)

func exitCode(err error) int {
if exitError, ok := err.(*exec.ExitError); ok {
var exitError *exec.ExitError
if errors.As(err, &exitError) {
return exitError.ProcessState.ExitCode()
}
return -1
Expand All @@ -22,7 +24,7 @@ func IsExitStatusError(err error) bool {
func IsExitStatusErrorStr(errString string) bool {
// https://golang.org/src/os/exec_posix.go?s=2421:2459#L87
// example exit status error string: exit status 1
var rex = regexp.MustCompile(`^exit status [0-9]{1,3}$`)
var rex = regexp.MustCompile(`^exit status \d{1,3}$`)
return rex.MatchString(errString)
}

Expand Down