-
Notifications
You must be signed in to change notification settings - Fork 1
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
Invalid lines silently stops parsing remaining lines #4
Comments
Refactor `dotenv::dotenv::Iter` to expose parse errors for those interested. The parse errors are structured as opaque strings to hide the parsing implementation details (currently nom and nom's errors are the internal currency). This allows a consumer that cares about propagating errors in `.env` files to use something like: ``` let env = dotenv::from_filename(".env")?; let mut iter = env.iter(); while let Some((key, value)) = iter.try_next()? { if std::env::var(key).is_err() { std::env::set_var(key, value); } } ``` Fixes arniu#4
I took a stab at this in #5 because I have a need for failing fast if |
Refactor `dotenv::dotenv::Iter` to expose parse errors for those interested. The parse errors are structured as opaque strings to hide the parsing implementation details (currently nom and nom's errors are the internal currency). This allows a consumer that cares about propagating errors in `.env` files to use something like: ``` let env = dotenv::from_filename(".env")?; let mut iter = env.iter(); while let Some((key, value)) = iter.try_next()? { if std::env::var(key).is_err() { std::env::set_var(key, value); } } ``` Fixes arniu#4
I'm now using a fork of this repo with #5 (See: a-scie/jump#180). I'd love to depend on the crate instead and I definitely don't want to introduce a forked crate (there are too many already!) for .env loading on crates.io. If there is anything I can do to help move this forward up to and including taking over / helping with maintenance for this project, I'd be happy to do so. |
Reference: allan2/dotenvy#11 (comment)
I've added the two
valid
lines, if you remove theC
line,D
will be included, likewise the unsetexport
line would also need to be removed forE
to be successfully parsed.It seems if any invalid line is encountered no further lines are parsed? They should probably raise an error, or at the very least continue parsing the valid lines?
The text was updated successfully, but these errors were encountered: