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

Closed
clifton opened this issue Aug 26, 2022 · 2 comments · Fixed by #123
Closed

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

clifton opened this issue Aug 26, 2022 · 2 comments · Fixed by #123
Milestone

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

Successfully merging a pull request may close this issue.

2 participants