Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [Unreleased]

### Changed
- `#[dotenvy::load]` now reports and exits on non-IO errors (such as parse errors) instead of silently ignoring them
- update to 2021 edition
- update MSRV to 1.74.0

Expand Down
17 changes: 9 additions & 8 deletions dotenvy-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@ pub fn load(attr: TokenStream, item: TokenStream) -> TokenStream {
};
let mut loader = EnvLoader::with_path(#path).sequence(seq);
if let Err(e) = unsafe { loader.load_and_modify() } {
if let Some(io_err) = e.source().and_then(|src| src.downcast_ref::<io::Error>()) {
match (io_err.kind(), #required) {
(io::ErrorKind::NotFound, false) => (),
_ => {
eprintln!("{e}");
process::exit(1);
}
let io_kind = e
.source()
.and_then(|src| src.downcast_ref::<io::Error>())
.map(io::Error::kind);
match (io_kind, #required) {
(Some(io::ErrorKind::NotFound), false) => (),
_ => {
eprintln!("{e}");
process::exit(1);
}
}

}
};

Expand Down