kamchatka-volcano / figcone

Read JSON, YAML, TOML, XML or INI configuration by declaring a struct
Microsoft Public License
100 stars 2 forks source link

Misleading error message #8

Closed MeanSquaredError closed 1 year ago

MeanSquaredError commented 1 year ago

Thank you for writing such a useful library. There is a slight problem with the error that is thrown when the library tries to load a non-existent file. E.g.

auto reader = figcone::ConfigReader {};
reader.readYamlFile<config_struct> ("non_existent.yaml");

It will say something along the lines of

terminate called after throwing an instance of 'figcone::ConfigError'
  what():  [line:1, column:1] Root node: Node 'database' is missing.
Aborted (core dumped)

The text in the figcone::ConfigError is misleading because it makes the user believe that the library opened the config file, but the file is not structured correctly. It should actually say that it could not find/open the configuration file.

kamchatka-volcano commented 1 year ago

Hi! Thanks for bringing it to my attention. I was aware that the file opening was done sloppily, but I forgot to fix it. I'll try to work on it as soon as possible.

kamchatka-volcano commented 1 year ago

@MeanSquaredError I've added some checks with better error messages, please update to v2.4.7

MeanSquaredError commented 1 year ago

@kamchatka-volcano Thank you!