feat: error on non-matching configuration entries
Alan Pearce alan@alanpearce.eu
Fri, 17 May 2024 16:45:47 +0200
1 files changed, 5 insertions(+), 0 deletions(-)
jump to
M internal/config/config.go → internal/config/config.go
@@ -191,11 +191,16 @@ } 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")