Improve error handling in configuration parsing

This commit is contained in:
Blallo 2021-06-01 12:12:22 +02:00
parent d906a3c547
commit afb7597f97
No known key found for this signature in database
GPG key ID: 0CBE577C9B72DC3F
3 changed files with 2 additions and 3 deletions

View file

@ -66,6 +66,7 @@ func main() {
fullConfig, err := config.Parse(configPath) fullConfig, err := config.Parse(configPath)
if err != nil { if err != nil {
Log.Error(err)
os.Exit(2) os.Exit(2)
} }

View file

@ -47,7 +47,7 @@ func (c CastingErrors) Check() bool {
if len(c.GeneralErrors) != 0 { if len(c.GeneralErrors) != 0 {
return false return false
} }
for _, err := range c.GeneralErrors { for _, err := range c.AccountErrors {
if err != nil { if err != nil {
return false return false
} }

View file

@ -3,7 +3,6 @@ package config
import ( import (
"errors" "errors"
"fmt" "fmt"
"log"
"os" "os"
"path" "path"
@ -21,7 +20,6 @@ func Parse(filePath string) (*MemConfig, error) {
} }
memConfig, castingErrs := parseConfig(fileConfig) memConfig, castingErrs := parseConfig(fileConfig)
if !castingErrs.Check() { if !castingErrs.Check() {
log.Print(castingErrs)
return nil, ErrFailedToParseConfig return nil, ErrFailedToParseConfig
} }
return memConfig, nil return memConfig, nil