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

Commit 5595c1a

Browse files
committed
add error channel
1 parent 2e44075 commit 5595c1a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

cmd/dep/status.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,12 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
363363

364364
logger.Println("Checking upstream projects:")
365365

366-
// BasicStatus channel
366+
// BasicStatus channel to collect all the BasicStatus
367367
bsCh := make(chan *BasicStatus, len(slp))
368368

369+
// Error channel to collect all the errors
370+
errorCh := make(chan error, len(slp))
371+
369372
var wg sync.WaitGroup
370373

371374
for i, proj := range slp {
@@ -387,7 +390,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
387390
ptr, err := sm.ListPackages(proj.Ident(), proj.Version())
388391

389392
if err != nil {
390-
// return digestMismatch, hasMissingPkgs, errors.Wrapf(err, "analysis of %s package failed", proj.Ident().ProjectRoot)
393+
errorCh <- err
391394
}
392395

393396
prm, _ := ptr.ToReachMap(true, false, false, nil)
@@ -452,8 +455,18 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
452455

453456
wg.Wait()
454457
close(bsCh)
458+
close(errorCh)
455459
logger.Println()
456460

461+
if len(errorCh) > 0 {
462+
bsErr := errors.New("failed to fetch updates")
463+
for err := range errorCh {
464+
ctx.Err.Println(err.Error())
465+
}
466+
ctx.Err.Println()
467+
return digestMismatch, hasMissingPkgs, bsErr
468+
}
469+
457470
// A map of ProjectRoot and *BasicStatus. This is used in maintain the
458471
// order of BasicStatus in output by collecting all the BasicStatus and
459472
// then using them in order.

0 commit comments

Comments
 (0)