Skip to content

Commit

Permalink
Return error with stderr value
Browse files Browse the repository at this point in the history
To maintain existing behaviour when not capturing stdout and stderr
  • Loading branch information
harrywhite4 committed Oct 28, 2019
1 parent 5d5ca0d commit b22b480
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/commands/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ func sanitisedCommandOutput(output []byte, err error) (string, error) {
outputString := string(output)
if err != nil {
// errors like 'exit status 1' are not very useful so we'll create an error
// from the combined output
if outputString == "" {
return "", WrapError(err)
// from stderr if we got an ExitError
exitError, ok := err.(*exec.ExitError)
if ok {
return outputString, errors.New(string(exitError.Stderr))
}
return outputString, errors.New(outputString)
return "", WrapError(err)
}
return outputString, nil
}
Expand Down

0 comments on commit b22b480

Please sign in to comment.