safe_config icon indicating copy to clipboard operation
safe_config copied to clipboard

Unexpected items in the config file should raise an exception

Open hoylen opened this issue 10 years ago • 5 comments

Can there be a mode where it raises an exception if something is found in the config file that does not match any member of the ConfigurationItem subclass? Currently, if there is something else in the config file, it is silently ignored.

The problem is, if you mistyped the name of a configuration item (and it is not mandatory), the program runs fine but does not produce the expected results. Until you spot the typo, you are left wondering why the configured value is not getting used.

hoylen avatar Oct 20 '16 06:10 hoylen

Makes sense. I'm wondering if that should be the default behavior and have a flag to turn it off. And keep an extra map of keys if that behavior is off.

itsjoeconway avatar Oct 21 '16 23:10 itsjoeconway

I think it should be the default behaviour (even though it is a breaking-change to the current behaviour). It is the "safer" behaviour. If someone wants to do things less safe, then they should make a deliberate choice to do it (and accept the consequences).

hoylen avatar Oct 21 '16 23:10 hoylen

@hoylen This issue has been resolved in 1.1.1. The "safer" behavior is now the only behavior: it throws an exception if an unexpected key is found.

JesseBlack82 avatar Nov 10 '16 16:11 JesseBlack82

Thank you for this feature.

It has already proved its usefulness, by detecting some slightly incorrect names I had in my config files.

hoylen avatar Nov 14 '16 22:11 hoylen

^ @MarcusSmith

JesseBlack82 avatar Nov 14 '16 23:11 JesseBlack82