Skip to content

Commit 658dc19

Browse files
committed
Add config error context
Config errors were thrown to CLI without saying that they\'re config errors. This fixes that.
1 parent 29dfeca commit 658dc19

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

payjoin-cli/src/app/config.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use std::net::SocketAddr;
22
use std::path::PathBuf;
33

4-
use anyhow::Result;
54
use clap::ArgMatches;
6-
use config::{Config, File, FileFormat};
5+
use config::{Config, ConfigError, File, FileFormat};
76
use serde::Deserialize;
87
use url::Url;
98

@@ -25,7 +24,7 @@ pub struct AppConfig {
2524
}
2625

2726
impl AppConfig {
28-
pub(crate) fn new(matches: &ArgMatches) -> Result<Self> {
27+
pub(crate) fn new(matches: &ArgMatches) -> Result<Self, ConfigError> {
2928
let builder = Config::builder()
3029
.set_default("bitcoind_rpchost", "http://localhost:18443")?
3130
.set_override_option(

payjoin-cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async fn main() -> Result<()> {
1616
env_logger::init();
1717

1818
let matches = cli();
19-
let config = AppConfig::new(&matches)?;
19+
let config = AppConfig::new(&matches).with_context(|| "Failed to parse config")?;
2020
let app = App::new(config)?;
2121

2222
match matches.subcommand() {

0 commit comments

Comments
 (0)