@@ -484,7 +484,7 @@ func installDependencies(workspace project.GoWorkspace) {
484484}
485485
486486// Run the extractor.
487- func extract (workspace project.GoWorkspace ) {
487+ func extract (workspace project.GoWorkspace ) bool {
488488 extractor , err := util .GetExtractorPath ()
489489 if err != nil {
490490 log .Fatalf ("Could not determine path of extractor: %v.\n " , err )
@@ -519,8 +519,11 @@ func extract(workspace project.GoWorkspace) {
519519 cmd .Stderr = os .Stderr
520520 err = cmd .Run ()
521521 if err != nil {
522- log .Fatalf ("Extraction failed: %s\n " , err .Error ())
522+ log .Printf ("Extraction failed for %s: %s\n " , workspace .BaseDir , err .Error ())
523+ return false
523524 }
525+
526+ return true
524527}
525528
526529// Build the project and run the extractor.
@@ -542,7 +545,8 @@ func installDependenciesAndBuild() {
542545 // Remove temporary extractor files (e.g. auto-generated go.mod files) when we are done
543546 defer project .RemoveTemporaryExtractorFiles ()
544547
545- for _ , workspace := range workspaces {
548+ // Attempt to extract all workspaces; we will tolerate individual extraction failures here
549+ for i , workspace := range workspaces {
546550 goVersionInfo := workspace .RequiredGoVersion ()
547551
548552 // This diagnostic is not required if the system Go version is 1.21 or greater, since the
@@ -606,7 +610,35 @@ func installDependenciesAndBuild() {
606610 }
607611 }
608612
609- extract (workspace )
613+ workspaces [i ].Extracted = extract (workspace )
614+ }
615+
616+ // Find all projects which could not be extracted successfully
617+ var unsuccessfulProjects = []string {}
618+
619+ for _ , workspace := range workspaces {
620+ if ! workspace .Extracted {
621+ unsuccessfulProjects = append (unsuccessfulProjects , workspace .BaseDir )
622+ }
623+ }
624+
625+ // If all projects could not be extracted successfully, we fail the overall extraction.
626+ if len (unsuccessfulProjects ) == len (workspaces ) {
627+ log .Fatalln ("Extraction failed for all discovered Go projects." )
628+ }
629+
630+ // If there is at least one project that could not be extracted successfully,
631+ // emit a diagnostic that reports which projects we could not extract successfully.
632+ // We only consider this a warning, since there may be test projects etc. which
633+ // do not matter if they cannot be extracted successfully.
634+ if len (unsuccessfulProjects ) > 0 {
635+ log .Printf (
636+ "Warning: extraction failed for %d project(s): %s\n " ,
637+ len (unsuccessfulProjects ),
638+ strings .Join (unsuccessfulProjects , ", " ))
639+ diagnostics .EmitExtractionFailedForProjects (unsuccessfulProjects )
640+ } else {
641+ log .Println ("Success: extraction succeeded for all discovered projects." )
610642 }
611643}
612644
0 commit comments