From 5595c1af4b24636c8de33503a986b219d49102cd Mon Sep 17 00:00:00 2001 From: Sunny Date: Thu, 7 Sep 2017 17:27:30 +0530 Subject: [PATCH] add error channel --- cmd/dep/status.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cmd/dep/status.go b/cmd/dep/status.go index 22e7db8097..8640cbb7e8 100644 --- a/cmd/dep/status.go +++ b/cmd/dep/status.go @@ -363,9 +363,12 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana logger.Println("Checking upstream projects:") - // BasicStatus channel + // BasicStatus channel to collect all the BasicStatus bsCh := make(chan *BasicStatus, len(slp)) + // Error channel to collect all the errors + errorCh := make(chan error, len(slp)) + var wg sync.WaitGroup for i, proj := range slp { @@ -387,7 +390,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana ptr, err := sm.ListPackages(proj.Ident(), proj.Version()) if err != nil { - // return digestMismatch, hasMissingPkgs, errors.Wrapf(err, "analysis of %s package failed", proj.Ident().ProjectRoot) + errorCh <- err } prm, _ := ptr.ToReachMap(true, false, false, nil) @@ -452,8 +455,18 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana wg.Wait() close(bsCh) + close(errorCh) logger.Println() + if len(errorCh) > 0 { + bsErr := errors.New("failed to fetch updates") + for err := range errorCh { + ctx.Err.Println(err.Error()) + } + ctx.Err.Println() + return digestMismatch, hasMissingPkgs, bsErr + } + // A map of ProjectRoot and *BasicStatus. This is used in maintain the // order of BasicStatus in output by collecting all the BasicStatus and // then using them in order.