all repos — searchix @ 6037d5c33e9b98360f61a4fe4f09659d0e3e6160

Search engine for NixOS, nix-darwin, home-manager and NUR users

fix: duplicate error logging on config parse error
Alan Pearce alan@alanpearce.eu
Fri, 17 May 2024 23:21:59 +0200
commit

6037d5c33e9b98360f61a4fe4f09659d0e3e6160

parent

82388e0abb013e3f2cd8c5659be44315658b777a

1 files changed, 3 insertions(+), 1 deletions(-)

jump to
M searchix.gosearchix.go
@@ -62,7 +62,9 @@ } 
 	cfg, err := config.GetConfig(*configFile)
 	if err != nil {
-		log.Panicf("error parsing configuration file: %v", err)
+		// only use log functions after the config file has been read successfully
+		fmt.Fprintf(os.Stderr, "error parsing configuration file: %v", err)
+		os.Exit(1)
 	}
 	slog.SetLogLoggerLevel(cfg.LogLevel)
 	if cfg.Web.Environment == "production" {