mehcode / config-rs

⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).
Apache License 2.0
2.43k stars 206 forks source link

Attach key to type error generated from Config::get_<type>() #413

Closed yuja closed 1 year ago

yuja commented 1 year ago

This commit extracts low-level get_value() to preserve the origin as much as possible. get::() would run Value-to-Value deserialization, and the origin field would be lost there.

For scalar types, we could instead leverage get::() as the deserializer implemented for Value type invokes Value::into_() function:

fn get_string(&self, key: &str) -> Result<String> { self.get(key) }
yuja commented 1 year ago

Sure, rebased. The tests passed locally.

matthiasbeyer commented 1 year ago

Thanks for contributing! :tada: