From 2d490bc00366dcafc1f3e592a001a7cf25a28d5d Mon Sep 17 00:00:00 2001 From: Nathan <148575555+nathan-artie@users.noreply.github.com> Date: Fri, 26 Jan 2024 16:50:02 -0800 Subject: [PATCH] Pull Fatal calls out of ReadConfig (#52) --- config/config.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index 22eca97c..96ba75dd 100644 --- a/config/config.go +++ b/config/config.go @@ -2,7 +2,6 @@ package config import ( "fmt" - "log" "os" "strings" @@ -116,17 +115,17 @@ func (s *Settings) Validate() error { func ReadConfig(fp string) (*Settings, error) { bytes, err := os.ReadFile(fp) if err != nil { - log.Fatalf("Failed to read config file, err: %v", err) + return nil, fmt.Errorf("failed to read config file, err: %w", err) } var settings Settings err = yaml.Unmarshal(bytes, &settings) if err != nil { - log.Fatalf("Failed to unmarshal config file, err: %v", err) + return nil, fmt.Errorf("failed to unmarshal config file, err: %w", err) } if err = settings.Validate(); err != nil { - log.Fatalf("Failed to validate config file, err: %v", err) + return nil, fmt.Errorf("failed to validate config file, err: %v", err) } return &settings, nil