Skip to content

Commit

Permalink
cmd/updatestd: print stderr in runOut when command fails
Browse files Browse the repository at this point in the history
Stderr is much more likely to contain useful information than
stdout in the unexpected case of the command failing. Show it.

For golang/go#55067.

Change-Id: Ice85e957bb7d9104da475d7616519bbfbae105e3
Reviewed-on: https://go-review.googlesource.com/c/build/+/431357
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
  • Loading branch information
dmitshur authored and gopherbot committed Sep 16, 2022
1 parent d7fb432 commit 03f4f13
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/updatestd/updatestd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"flag"
"fmt"
"go/ast"
Expand Down Expand Up @@ -278,6 +279,9 @@ func (r runner) runOut(args ...string) []byte {
out, err := cmd.Output()
if err != nil {
log.Printf("> %s\n", strings.Join(args, " "))
if ee := (*exec.ExitError)(nil); errors.As(err, &ee) {
out = append(out, ee.Stderr...)
}
log.Fatalf("command failed: %s\n%s", err, out)
}
return out
Expand Down

0 comments on commit 03f4f13

Please sign in to comment.