Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
add error channel
Browse files Browse the repository at this point in the history
  • Loading branch information
darkowlzz committed Sep 7, 2017
1 parent 2e44075 commit 5595c1a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cmd/dep/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 5595c1a

Please sign in to comment.