aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/mvs/mvs_test.go
diff options
context:
space:
mode:
authorJay Conrod <jayconrod@google.com>2019-03-11 18:53:08 -0400
committerJay Conrod <jayconrod@google.com>2019-04-03 18:00:56 +0000
commit1e3cdd1edce67350f8007e4a9b9b555f1e27c5b4 (patch)
tree27da504871234bf4adb147096acfad96834a121e /src/cmd/go/internal/mvs/mvs_test.go
parent8c896aa46655cfbdfd9971fb16a830046fcdf81c (diff)
downloadgo-1e3cdd1edce67350f8007e4a9b9b555f1e27c5b4.tar.gz
go-1e3cdd1edce67350f8007e4a9b9b555f1e27c5b4.zip
cmd/go: print require chains in build list errors
mvs.BuildList and functions that invoke it directly (UpgradeAll) now return an *mvs.BuildListError when there is an error retrieving the requirements for a module. This new error prints the chain of requirements from the main module to the module where the error occurred. These errors come up most commonly when a go.mod file has an unexpected module path or can't be parsed for some other reason. It's currently difficult to debug these errors because it's not clear where the "bad" module is required from. Tools like "go list -m" and "go mod why" don't work without the build graph. Fixes #30661 Change-Id: I3c9d4683dcd9a5d7c259e5e4cc7e1ee209700b10 Reviewed-on: https://go-review.googlesource.com/c/go/+/166984 Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/go/internal/mvs/mvs_test.go')
-rw-r--r--src/cmd/go/internal/mvs/mvs_test.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/cmd/go/internal/mvs/mvs_test.go b/src/cmd/go/internal/mvs/mvs_test.go
index 2a27dfb288..cab4bb241b 100644
--- a/src/cmd/go/internal/mvs/mvs_test.go
+++ b/src/cmd/go/internal/mvs/mvs_test.go
@@ -5,6 +5,7 @@
package mvs
import (
+ "fmt"
"reflect"
"strings"
"testing"
@@ -446,7 +447,7 @@ func (r reqsMap) Upgrade(m module.Version) (module.Version, error) {
}
}
if u.Path == "" {
- return module.Version{}, &MissingModuleError{module.Version{Path: m.Path, Version: ""}}
+ return module.Version{}, fmt.Errorf("missing module: %v", module.Version{Path: m.Path})
}
return u, nil
}
@@ -467,7 +468,7 @@ func (r reqsMap) Previous(m module.Version) (module.Version, error) {
func (r reqsMap) Required(m module.Version) ([]module.Version, error) {
rr, ok := r[m]
if !ok {
- return nil, &MissingModuleError{m}
+ return nil, fmt.Errorf("missing module: %v", m)
}
return rr, nil
}