diff options
author | Alan Pearce | 2024-05-17 16:45:47 +0200 |
---|---|---|
committer | Alan Pearce | 2024-05-17 16:45:47 +0200 |
commit | 64881323e89d6d9b96865a5fa6f2150b826683db (patch) | |
tree | 6560eea49d001a73620474d3f2e9fe43933bf66c /internal | |
parent | 8805c25adece20e4bee90faf0052804a3bfbab32 (diff) | |
download | searchix-64881323e89d6d9b96865a5fa6f2150b826683db.tar.lz searchix-64881323e89d6d9b96865a5fa6f2150b826683db.tar.zst searchix-64881323e89d6d9b96865a5fa6f2150b826683db.zip |
feat: error on non-matching configuration entries
Diffstat (limited to 'internal')
-rw-r--r-- | internal/config/config.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index 88bc006..6837ea7 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -191,12 +191,17 @@ func GetConfig(filename string) (*Config, error) { defer f.Close() dec := toml.NewDecoder(f) + dec.DisallowUnknownFields() err = dec.Decode(&config) if err != nil { var tomlError *toml.DecodeError if errors.As(err, &tomlError) { return nil, errors.WithMessage(err, tomlError.Error()) } + var missingConfigError *toml.StrictMissingError + if errors.As(err, &missingConfigError) { + return nil, errors.Errorf("unexpected config: %s", missingConfigError.String()) + } return nil, errors.Wrap(err, "config error") } |