Skip to content

Commit

Permalink
Pull Fatal calls out of ReadConfig (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-artie authored Jan 27, 2024
1 parent 96ba1e0 commit 2d490bc
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package config

import (
"fmt"
"log"
"os"
"strings"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2d490bc

Please sign in to comment.