Hey @softprops,
I encountered the problem of error accuracy when working with envy.
This issue seems vaguely relevant, but it's missing any description, so I decided to create a new one.
The problem
Basically given code like this
struct Env {
pub some_var: String
}
fn main() {
let _env = envy::prefixed("ABC_")
.from_env::<Env>().unwrap();
}
I'm getting an error like this:
where I'd like to see an error like this:
MissingValue("ABC_SOME_VAR")
Quick solution
I was able to overcome this in my project by a quick hack:
panic!("Missing value: ABC_{}", err.to_string().split_whitespace().last().unwrap().to_uppercase());
but obviously it would be better if envy just had nicer errors in the first place.
Proposal
I would be happy to introduce a PR, improving the error messages and adjusting the behavior for prefixed variables. Let me know if you're interested in seeing this, is the proposed improvement acceptable, and I'll work on it.
Hey @softprops,
I encountered the problem of error accuracy when working with
envy.This issue seems vaguely relevant, but it's missing any description, so I decided to create a new one.
The problem
Basically given code like this
I'm getting an error like this:
where I'd like to see an error like this:
Quick solution
I was able to overcome this in my project by a quick hack:
but obviously it would be better if
envyjust had nicer errors in the first place.Proposal
I would be happy to introduce a PR, improving the error messages and adjusting the behavior for prefixed variables. Let me know if you're interested in seeing this, is the proposed improvement acceptable, and I'll work on it.