rust-cli / confy

🛋 Zero-boilerplate configuration management in Rust
Other
896 stars 59 forks source link

Confy panics when loading a configuration file with missing fields #11

Closed yuvallanger closed 5 years ago

yuvallanger commented 5 years ago

The unwrap call unwrapping toml::from_str's output in line 105 of /src/lib.rs (currently in master 7115b65c0b871494358cc4890304623cb64dfe84 and 0.3.1 95b1aac1e236ca32f19221709da4e29177308039) 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.

yuvallanger commented 5 years ago

Maybe replace all unwraps with context specific ConfyError?

Dylan-DPC-zz commented 5 years ago

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