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)
if err != nil {
Log.Error(err)
os.Exit(2)
}

View file

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

View file

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