cmd/govulncheck_sandbox: propagate govulncheck output

In the case of errors with govulncheck execution, we want to propagate
the error message produced by govulncheck. This is needed for error
categorization. Otherwise, one often gets just "exit status 1".

Change-Id: I88e29cadb20e1b74b965c91acdcaa9b05a13664a
Reviewed-on: https://go-review.googlesource.com/c/pkgsite-metrics/+/477595
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/cmd/govulncheck_sandbox/govulncheck_sandbox.go b/cmd/govulncheck_sandbox/govulncheck_sandbox.go
index dc54ab7..94c252d 100644
--- a/cmd/govulncheck_sandbox/govulncheck_sandbox.go
+++ b/cmd/govulncheck_sandbox/govulncheck_sandbox.go
@@ -80,12 +80,12 @@
 	govulncheckCmd.Dir = dir
 	govulncheckCmd.Env = append(govulncheckCmd.Environ(), "GOVULNDB=file://"+vulnDBDir)
 	start := time.Now()
-	output, err := govulncheckCmd.Output()
+	output, err := govulncheckCmd.CombinedOutput()
 	if err != nil {
 		// Temporary check because govulncheck currently exits code 3 if any vulns
 		// are found but no other errors occurred.
 		if e := (&exec.ExitError{}); !errors.As(err, &e) || e.ProcessState.ExitCode() != 3 {
-			return nil, err
+			return nil, fmt.Errorf("govulncheck error: err=%v out=%s", err, output)
 		}
 	}
 	response := govulncheck.SandboxResponse{}
diff --git a/cmd/govulncheck_sandbox/govulncheck_sandbox_test.go b/cmd/govulncheck_sandbox/govulncheck_sandbox_test.go
index 469b0f2..486b79c 100644
--- a/cmd/govulncheck_sandbox/govulncheck_sandbox_test.go
+++ b/cmd/govulncheck_sandbox/govulncheck_sandbox_test.go
@@ -71,7 +71,6 @@
 		if resp.Stats.ScanMemory <= 0 {
 			t.Errorf("got %d; want >0 scan memory", resp.Stats.ScanMemory)
 		}
-
 	})
 
 	t.Run("binary", func(t *testing.T) {
@@ -107,7 +106,7 @@
 			name:   "no vulndb",
 			args:   []string{govulncheckPath, worker.ModeGovulncheck, "testdata/module"},
 			vulndb: "does not exist",
-			want:   "exit status 1",
+			want:   "does not exist",
 		},
 		{
 			name:   "no mode",