sweet: print additional details during a subprocess failure

This change also updates the places that print errors to use log.Error
instead of rolling their own methods.

Change-Id: I4a858f43213c4cd9ade1d777795f380977b87f1b
Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/383536
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
pull/2/head
Michael Anthony Knyszek 2022-02-05 05:28:32 +00:00 committed by Michael Knyszek
parent 680e04bb53
commit 095f870b25
3 changed files with 6 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import (
"unicode/utf8"
"golang.org/x/benchmarks/sweet/common"
"golang.org/x/benchmarks/sweet/common/log"
)
const (
@ -128,7 +129,7 @@ func Run() int {
}
chosen.flags.Parse(os.Args[2:])
if err := chosen.Run(chosen.flags.Args()); err != nil {
fmt.Fprintf(out, "error: %v\n", err)
log.Error(err)
return 1
}
return 0

View File

@ -313,7 +313,7 @@ func (c *runCmd) Run(args []string) error {
return err
}
errEncountered = true
log.Printf("error: %v\n", err)
log.Error(err)
}
}
if errEncountered {

View File

@ -118,4 +118,7 @@ func Print(args ...interface{}) {
func Error(err error) {
actLog.Printf("error: %v", err)
if e, ok := err.(*exec.ExitError); ok {
actLog.Printf("output:\n%s", string(e.Stderr))
}
}