about summary refs log tree commit diff stats
path: root/internal/importer
diff options
context:
space:
mode:
authorAlan Pearce2024-05-20 23:38:43 +0200
committerAlan Pearce2024-05-20 23:38:43 +0200
commitc821da1cf55864852bcd8f337dd7acd0cc02f0b9 (patch)
tree9502d273ce470195c0dd56e71a3455243fcedae3 /internal/importer
parente72d9caabfd825db660733abe3082426dc2c3838 (diff)
downloadsearchix-c821da1cf55864852bcd8f337dd7acd0cc02f0b9.tar.lz
searchix-c821da1cf55864852bcd8f337dd7acd0cc02f0b9.tar.zst
searchix-c821da1cf55864852bcd8f337dd7acd0cc02f0b9.zip
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
Diffstat (limited to 'internal/importer')
-rw-r--r--internal/importer/main.go28
1 files 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)