Skip to content

Commit 5740d3b

Browse files
committed
dev: add notes about error management
1 parent 23ceda3 commit 5740d3b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/goanalysis/runner_loadingpackage.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ func (lp *loadingPackage) analyze(ctx context.Context, cancel context.CancelFunc
7878
defer lp.decUse(loadMode < LoadModeWholeProgram)
7979

8080
if err := lp.loadWithFacts(loadMode); err != nil {
81+
// Note: this error is not ignored when there is no facts loading (e.g. with 98% of linters).
82+
// But this is not a problem because the errors are added to the package.Errors.
83+
// You through an error, try to add it to actions, but there is no action annnddd it's gone!
8184
werr := fmt.Errorf("failed to load package %s: %w", lp.pkg.Name, err)
8285

8386
// Don't need to write error to errCh, it will be extracted and reported on another layer.
@@ -239,9 +242,11 @@ func (lp *loadingPackage) loadFromExportData() error {
239242
return fmt.Errorf("dependency %q hasn't been loaded yet", path)
240243
}
241244
}
245+
242246
if pkg.ExportFile == "" {
243247
return fmt.Errorf("no export data for %q", pkg.ID)
244248
}
249+
245250
f, err := os.Open(pkg.ExportFile)
246251
if err != nil {
247252
return err
@@ -332,6 +337,7 @@ func (lp *loadingPackage) loadImportedPackageWithFacts(loadMode LoadMode) error
332337
if srcErr := lp.loadFromSource(loadMode); srcErr != nil {
333338
return srcErr
334339
}
340+
335341
// Make sure this package can't be imported successfully
336342
pkg.Errors = append(pkg.Errors, packages.Error{
337343
Pos: "-",

0 commit comments

Comments
 (0)