Skip to content

Commit 4450faa

Browse files
committed
Don't silently fail to load config in cli
Before we would silently drop the config if we failed to parse it. This can cause confusion as to why your cli isn't working correctly. Now if you have a config file it'll throw an error if we can't parse it instead of silently dropping it.
1 parent 729308c commit 4450faa

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

ldk-server-cli/src/main.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,20 @@ async fn main() {
563563
}
564564

565565
let config_path = cli.config.map(PathBuf::from).or_else(get_default_config_path);
566-
let config = config_path.as_ref().and_then(|p| load_config(p).ok());
566+
let config = match config_path.as_ref() {
567+
None => None,
568+
Some(path) => {
569+
if path.is_file() {
570+
let cfg = load_config(path).unwrap_or_else(|e| {
571+
eprintln!("Failed to load config file '{}': {}", path.display(), e);
572+
std::process::exit(1);
573+
});
574+
Some(cfg)
575+
} else {
576+
None
577+
}
578+
},
579+
};
567580

568581
let api_key = resolve_api_key(cli.api_key, config.as_ref()).unwrap_or_else(|| {
569582
eprintln!("API key not provided. Use --api-key or ensure the api_key file exists at {DEFAULT_DIR}/[network]/api_key");

0 commit comments

Comments
 (0)