dotenvy icon indicating copy to clipboard operation
dotenvy copied to clipboard

Better default error for `var(...)`

Open clifton opened this issue 3 years ago • 2 comments

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: EnvVar(NotPresent)'

I was looking into mapping the error and adding context (eg, "missing VAR_XYZ"), but it would be a breaking API change. Any suggestions for how to structure that change?

clifton avatar Aug 26 '22 18:08 clifton

This is a great idea that is definitely worth implementing. I opened a discussion (#25) for this.

Maybe something like this?

// dotenvy::Error
enum Error {
    LineParse(String, usize),
    Io(Error),
    EnvVar(VarError, String),  // name is here
}

This is just a suggestion. It could be possible that the name information could be used for other variants like LineParse, I am not sure yet.

allan2 avatar Oct 14 '22 18:10 allan2

Great, thanks

clifton avatar Oct 14 '22 18:10 clifton