Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better default error for var(...) #14

Open
clifton opened this issue Aug 26, 2022 · 2 comments
Open

Better default error for var(...) #14

clifton opened this issue Aug 26, 2022 · 2 comments

Comments

@clifton
Copy link

clifton commented Aug 26, 2022

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?

@allan2
Copy link
Owner

allan2 commented Oct 14, 2022

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.

@clifton
Copy link
Author

clifton commented Oct 14, 2022

Great, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants