github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/go/internal/mvs/errors.go (about) 1 // Copyright 2020 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package mvs 6 7 import ( 8 "golang.org/x/mod/module" 9 ) 10 11 // BuildListError decorates an error that occurred gathering requirements 12 // while constructing a build list. BuildListError prints the chain 13 // of requirements to the module where the error occurred. 14 type BuildListError struct { 15 Err error 16 stack []buildListErrorElem 17 } 18 19 // NewBuildListError returns a new BuildListError wrapping an error that 20 // occurred at a module found along the given path of requirements and/or 21 // upgrades, which must be non-empty. 22 // 23 // The isVersionChange function reports whether a path step is due to an 24 // explicit upgrade or downgrade (as opposed to an existing requirement in a 25 // go.mod file). A nil isVersionChange function indicates that none of the path 26 // steps are due to explicit version changes. 27 func NewBuildListError(err error, path []module.Version, isVersionChange func(from, to module.Version) bool) *BuildListError 28 29 // Module returns the module where the error occurred. If the module stack 30 // is empty, this returns a zero value. 31 func (e *BuildListError) Module() module.Version 32 33 func (e *BuildListError) Error() string 34 35 func (e *BuildListError) Unwrap() error