Skip to content

Commit

Permalink
fix(core): improve error message for missing lightning root folder
Browse files Browse the repository at this point in the history
This commit addresses the scenario where the lightning root folder is not found. Previously, Coffee would provide a generic error message (path not found), causing confusion.

With this update, the error message has been refined to provide more clarity. Now, if the lightning root folder is not found, the error message specifically states: The path {lightning_path} does not exist.

Signed-off-by: Tarek <[email protected]>
  • Loading branch information
tareknaser committed Dec 5, 2023
1 parent 27a285c commit 76ad241
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions coffee_core/src/coffee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use std::collections::HashMap;
use std::fmt::Debug;
use std::path::Path;
use std::vec::Vec;
use tokio::fs;

Expand Down Expand Up @@ -201,6 +202,17 @@ impl CoffeeManager {
self.rpc = Some(rpc);
let path = self.config.cln_config_path.clone();
let path = path.ok_or_else(|| error!("cln config path not found."))?;

// The path is the path of the cln config file (eg. ~/.lightning/bitcoin/config)
// We need to check that the root folder (eg. ~/.lightning/bitcoin) exists
// otherwise we return an error.

// We can unwrap here because we are sure that the path ends with /config
let lightning_path = path.strip_suffix("/config").unwrap();
if !Path::new(&lightning_path).exists() {
return Err(error!("The path {lightning_path} does not exist"));
}

let mut file = CLNConf::new(path.clone(), true);
log::info!("looking for the cln config: {path}");
file.parse()
Expand Down

0 comments on commit 76ad241

Please sign in to comment.