@@ -350,22 +350,24 @@ type MissingStatus struct {
350
350
351
351
// errorStatus contains information about error and number of status failures.
352
352
type errorStatus struct {
353
- err error
353
+ err error
354
+ // count is for counting errors due to which we don't fail completely, but
355
+ // return partial results with missing/unknown data.
354
356
count int
355
357
}
356
358
357
- func runStatusAll (ctx * dep.Ctx , out outputter , p * dep.Project , sm gps.SourceManager ) (bool , bool , errorStatus ) {
358
- var digestMismatch , hasMissingPkgs bool
359
-
359
+ func runStatusAll (ctx * dep.Ctx , out outputter , p * dep.Project , sm gps.SourceManager ) (digestMismatch bool , hasMissingPkgs bool , errStatus errorStatus ) {
360
360
if p .Lock == nil {
361
- return digestMismatch , hasMissingPkgs , errorStatus {err : errors .Errorf ("no Gopkg.lock found. Run `dep ensure` to generate lock file" )}
361
+ errStatus .err = errors .Errorf ("no Gopkg.lock found. Run `dep ensure` to generate lock file" )
362
+ return digestMismatch , hasMissingPkgs , errStatus
362
363
}
363
364
364
365
// While the network churns on ListVersions() requests, statically analyze
365
366
// code from the current project.
366
367
ptree , err := pkgtree .ListPackages (p .ResolvedAbsRoot , string (p .ImportRoot ))
367
368
if err != nil {
368
- return digestMismatch , hasMissingPkgs , errorStatus {err : errors .Wrapf (err , "analysis of local packages failed" )}
369
+ errStatus .err = errors .Wrapf (err , "analysis of local packages failed" )
370
+ return digestMismatch , hasMissingPkgs , errStatus
369
371
}
370
372
371
373
// Set up a solver in order to check the InputHash.
@@ -390,7 +392,8 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
390
392
391
393
s , err := gps .Prepare (params , sm )
392
394
if err != nil {
393
- return digestMismatch , hasMissingPkgs , errorStatus {err : errors .Wrapf (err , "could not set up solver for input hashing" )}
395
+ errStatus .err = errors .Wrapf (err , "could not set up solver for input hashing" )
396
+ return digestMismatch , hasMissingPkgs , errStatus
394
397
}
395
398
396
399
cm := collectConstraints (ptree , p , sm )
@@ -517,12 +520,9 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
517
520
// Newline after printing the status progress output
518
521
logger .Println ()
519
522
520
- var statusError error
521
- var errorCount int
522
-
523
523
// List Packages errors. This would happen only for dot output.
524
524
if len (errListPkgCh ) > 0 {
525
- statusError = errFailedListPkg
525
+ errStatus . err = errFailedListPkg
526
526
if ctx .Verbose {
527
527
for err := range errListPkgCh {
528
528
ctx .Err .Println (err .Error ())
@@ -533,13 +533,15 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
533
533
534
534
// List Version errors
535
535
if len (errListVerCh ) > 0 {
536
- if statusError == errFailedListPkg {
537
- statusError = errMultipleFailures
536
+ if errStatus . err == nil {
537
+ errStatus . err = errFailedUpdate
538
538
} else {
539
- statusError = errFailedUpdate
539
+ errStatus . err = errMultipleFailures
540
540
}
541
541
542
- errorCount = len (errListVerCh )
542
+ // Count ListVersions error because we get partial results when
543
+ // this happens.
544
+ errStatus .count = len (errListVerCh )
543
545
if ctx .Verbose {
544
546
for err := range errListVerCh {
545
547
ctx .Err .Println (err .Error ())
@@ -563,7 +565,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
563
565
564
566
out .BasicFooter ()
565
567
566
- return digestMismatch , hasMissingPkgs , errorStatus { err : statusError , count : errorCount }
568
+ return digestMismatch , hasMissingPkgs , errStatus
567
569
}
568
570
569
571
// Hash digest mismatch may indicate that some deps are no longer
0 commit comments