From 9ee337a22defeb3cec524879c74b1d12f1d793f6 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Fri, 27 Dec 2024 17:38:24 -0700 Subject: [PATCH] Show failed command and its output. Not the cleanest way to show the command being used, but at least this way we capture any output it produces and show it to the user to give them a clue about what they can do. --- internal/generate/generate.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/generate/generate.go b/internal/generate/generate.go index 8980d0f..463e57a 100644 --- a/internal/generate/generate.go +++ b/internal/generate/generate.go @@ -71,7 +71,11 @@ func common(directory string) ([]*goModDownload, map[string]string, error) { cmd.Dir = directory stdout, err := cmd.Output() if err != nil { - return nil, nil, err + if exiterr, ok := err.(*exec.ExitError); ok { + return nil, nil, fmt.Errorf("Failed to run 'go mod download --json: %s\n%s", exiterr, exiterr.Stderr) + } else { + return nil, nil, fmt.Errorf("Failed to run 'go mod download --json': %s", err) + } } dec := json.NewDecoder(bytes.NewReader(stdout))