From c821da1cf55864852bcd8f337dd7acd0cc02f0b9 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 20 May 2024 23:38:43 +0200 Subject: fix(importer): abort import of current source in case of error The switch to logger.Error is to make clear that the operation is aborted, whereas the remaining warning (fetching the git revision) is not so important so it remains a warning and does not skip the current iteration --- internal/importer/main.go | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/internal/importer/main.go b/internal/importer/main.go index 5343e81..663e8eb 100644 --- a/internal/importer/main.go +++ b/internal/importer/main.go @@ -46,7 +46,7 @@ func Start( fetcher, err := fetcher.New(source, fetcherDataPath, logger) if err != nil { - logger.Warn("error creating fetcher", "error", err) + logger.Error("error creating fetcher", "error", err) continue } @@ -58,10 +58,20 @@ func Start( if errors.As(err, &exerr) { lines := strings.Split(strings.TrimSpace(string(exerr.Stderr)), "\n") for _, line := range lines { - logger.Warn("importer fetch failed", "stderr", line, "status", exerr.ExitCode()) + logger.Error( + "importer fetch failed", + "stderr", + line, + "status", + exerr.ExitCode(), + ) + + continue } } else { - logger.Warn("importer fetch failed", "error", err) + logger.Error("importer fetch failed", "error", err) + + continue } continue @@ -87,7 +97,9 @@ func Start( ) file, err = openFileDecoded(files.Options) if err != nil { - logger.Warn("could not open file", "filename", files.Options, "error", err) + logger.Error("could not open file", "filename", files.Options, "error", err) + + continue } processor, err = NewOptionProcessor(file, source) case config.Packages: @@ -100,12 +112,16 @@ func Start( ) file, err = openFileDecoded(files.Packages) if err != nil { - logger.Warn("could not open file", "filename", files.Packages, "error", err) + logger.Error("could not open file", "filename", files.Packages, "error", err) + + continue } processor, err = NewPackageProcessor(file, source) } if err != nil { - logger.Warn("failed to create processor", "type", source.Importer, "error", err) + logger.Error("failed to create processor", "type", source.Importer, "error", err) + + continue } hadWarnings := process(ctx, indexer, processor, logger) -- cgit 1.4.1