Skip to content

Commit 35511cd

Browse files
committed
Propagate error if the fs read for ohttp keys fails during config
1 parent ad3f686 commit 35511cd

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

payjoin-cli/src/app/config.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,27 +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-
std::fs::read(s)
106-
.map_err(|e| {
107-
log::error!("Failed to read ohttp_keys file: {}", e);
108-
ConfigError::Message(format!(
109-
"Failed to read ohttp_keys file: {}",
110-
e
111-
))
112-
})
113-
.ok()
114-
}),
115-
)?
112+
.set_override_option("ohttp_keys", ohttp_keys)?
116113
};
117114

118115
let max_fee_rate = matches

0 commit comments

Comments
 (0)