Skip to content

Commit

Permalink
Propagate error if the fs read for ohttp keys fails during config
Browse files Browse the repository at this point in the history
  • Loading branch information
shinghim committed Dec 9, 2024
1 parent ad3f686 commit 35511cd
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions payjoin-cli/src/app/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,24 @@ impl AppConfig {
)?
};

#[cfg(feature = "v2")]
let ohttp_keys = matches
.get_one::<String>("ohttp_keys")
.map(|s| std::fs::read(s))
.transpose()
.map_err(|e| {
log::error!("Failed to read ohttp_keys file: {}", e);
ConfigError::Message(format!("Failed to read ohttp_keys file: {}", e))
})?;

#[cfg(feature = "v2")]
let builder = {
builder
.set_override_option(
"pj_directory",
matches.get_one::<Url>("pj_directory").map(|s| s.as_str()),
)?
.set_override_option(
"ohttp_keys",
matches.get_one::<String>("ohttp_keys").and_then(|s| {
std::fs::read(s)
.map_err(|e| {
log::error!("Failed to read ohttp_keys file: {}", e);
ConfigError::Message(format!(
"Failed to read ohttp_keys file: {}",
e
))
})
.ok()
}),
)?
.set_override_option("ohttp_keys", ohttp_keys)?
};

let max_fee_rate = matches
Expand Down

0 comments on commit 35511cd

Please sign in to comment.