builder/vmware: workstation 9 show stderr if command fails

This commit is contained in:
Mitchell Hashimoto 2013-07-16 14:46:34 -07:00
parent badd5df3cd
commit d126c45d77
1 changed files with 9 additions and 2 deletions

View File

@ -143,8 +143,15 @@ func (d *Workstation9LinuxDriver) runAndLog(cmd *exec.Cmd) (string, string, erro
cmd.Stderr = &stderr
err := cmd.Run()
log.Printf("stdout: %s", strings.TrimSpace(stdout.String()))
log.Printf("stderr: %s", strings.TrimSpace(stderr.String()))
stdoutString := strings.TrimSpace(stdout.String())
stderrString := strings.TrimSpace(stderr.String())
if _, ok := err.(*exec.ExitError); ok {
err = fmt.Errorf("VMware error: %s", stderrString)
}
log.Printf("stdout: %s", stdoutString)
log.Printf("stderr: %s", stderrString)
return stdout.String(), stderr.String(), err
}