papero/config/parse.go
2021-01-09 17:06:13 +01:00

21 lines
426 B
Go

package config
import (
"errors"
"log"
)
var ErrFailedToParseConfig = errors.New("unable to cast into usable configuration")
func Parse(filePath string) (*MemConfig, error) {
fileConfig, err := parseFile(filePath)
if err != nil {
return nil, err
}
memConfig, castingErrs := parseConfig(fileConfig)
if !castingErrs.Check() {
log.Print(castingErrs)
return nil, ErrFailedToParseConfig
}
return memConfig, nil
}