Skip to content

Commit

Permalink
mirror: add logging for go errors
Browse files Browse the repository at this point in the history
This can fail sometimes and the error message is very unclear. Add
logging so we can gather more data.

Epic: none
Release note: None
  • Loading branch information
rickystewart committed Aug 24, 2023
1 parent 7164cad commit 9a1a988
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/cmd/mirror/go/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,12 @@ func downloadZips(
cmd.Dir = tmpdir
jsonBytes, err := cmd.Output()
if err != nil {
return nil, err
var stderr []byte
if exitErr := (*exec.ExitError)(nil); errors.As(err, &exitErr) {
stderr = exitErr.Stderr
}
return nil, fmt.Errorf("failed to run go with arguments %+v; got stdout %s, stderr %s; %w",
downloadArgs, string(jsonBytes), string(stderr), err)
}
var jsonBuilder strings.Builder
ret := make(map[string]downloadedModule)
Expand All @@ -184,7 +189,12 @@ func listAllModules(tmpdir string) (map[string]listedModule, error) {
cmd.Dir = tmpdir
jsonBytes, err := cmd.Output()
if err != nil {
return nil, err
var stderr []byte
if exitErr := (*exec.ExitError)(nil); errors.As(err, &exitErr) {
stderr = exitErr.Stderr
}
return nil, fmt.Errorf("failed to run `go list -mod=readonly -m -json all`; got stdout %s, stderr %s; %w",
string(jsonBytes), string(stderr), err)
}
ret := make(map[string]listedModule)
var jsonBuilder strings.Builder
Expand Down

0 comments on commit 9a1a988

Please sign in to comment.