Skip to content

Commit 5689408

Browse files
committed
Propagate error if the filesystem read for ohttp keys fails during config
1 parent 48ec4ba commit 5689408

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

payjoin-cli/src/app/config.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,25 +92,24 @@ impl AppConfig {
9292
)?
9393
};
9494

95+
#[cfg(feature = "v2")]
96+
let ohttp_keys = matches
97+
.get_one::<String>("ohttp_keys")
98+
.map(|s| std::fs::read(s))
99+
.transpose()
100+
.map_err(|e| {
101+
log::error!("Failed to read ohttp_keys file: {}", e);
102+
ConfigError::Message(format!("Failed to read ohttp_keys file: {}", e))
103+
})?;
104+
95105
#[cfg(feature = "v2")]
96106
let builder = {
97107
builder
98108
.set_override_option(
99109
"pj_directory",
100110
matches.get_one::<Url>("pj_directory").map(|s| s.as_str()),
101111
)?
102-
.set_override_option(
103-
"ohttp_keys",
104-
matches.get_one::<String>("ohttp_keys").and_then(|s| {
105-
Some(std::fs::read(s).map_err(|e| {
106-
log::error!("Failed to read ohttp_keys file: {}", e);
107-
ConfigError::Message(format!(
108-
"Failed to read ohttp_keys file: {}",
109-
e
110-
))
111-
})?)
112-
}),
113-
)?
112+
.set_override_option("ohttp_keys", ohttp_keys)
114113
};
115114

116115
let max_fee_rate = matches

0 commit comments

Comments
 (0)