rust-cli/confy

Confy panics when loading a configuration file with missing fields

Closed this issue · 2 comments

The unwrap call unwrapping toml::from_str's output in line 105 of /src/lib.rs (currently in master 7115b65 and 0.3.1 95b1aac) does that:

Ok(mut cfg) => Ok(toml::from_str(&cfg.get_string().unwrap()).unwrap()),

Will it be reasonable to create an enum ConfyError { BadTomlData } so I could return it in the load function at the point of toml::from_str's failure?

It would change load's type signature into a more general one or a totally different one if we return both IoErrors and ConfyError as Error trait values, I am not sure, so it might not be a good idea.

Maybe replace all unwraps with context specific ConfyError?

This is resolved by #12. We don't have any unwraps left in the code (🎉) so closing this. Thanks