Skip to content

Commit

Permalink
feat(core): improve error message
Browse files Browse the repository at this point in the history
The error message displayed in case of a missing Core Lightning configuration file has been enhanced to provide users with more friendly and actionable information.

Now, when coffee fails to find the configuration file at the specified path, it advises users to resolve the issue by running the coffee setup <cln_path> command, helping them quickly address the problem and proceed smoothly.

Signed-off-by: Tarek <[email protected]>
  • Loading branch information
tareknaser committed Oct 20, 2023
1 parent f59756b commit 497b721
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions coffee_core/src/coffee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,14 @@ impl CoffeeManager {
if self.config.cln_config_path.is_none() {
return Ok(());
}
let root = self.config.cln_root.clone().unwrap();
let root = self.config.cln_root.clone();
let root =
root.ok_or_else(|| error!("cln root path not found, please run `coffee setup`"))?;
let rpc = Client::new(format!("{root}/{}/lightning-rpc", self.config.network));
self.rpc = Some(rpc);
let path = self.config.cln_config_path.clone().unwrap();
let path = self.config.cln_config_path.clone();
let path =
path.ok_or_else(|| error!("cln config path not found, please run `coffee setup`"))?;
let mut file = CLNConf::new(path.clone(), true);
log::info!("looking for the cln config: {path}");
file.parse()
Expand All @@ -217,7 +221,9 @@ impl CoffeeManager {
self.config.cln_config_path = Some(path_with_network);
self.config.cln_root = Some(cln_dir.to_owned());
self.load_cln_conf().await?;
let mut conf = self.cln_config.clone().unwrap();
let conf = self.cln_config.clone();
let mut conf =
conf.ok_or_else(|| error!("cln config path not found, please run `coffee setup`"))?;
conf.add_subconf(self.coffee_cln_config.clone())
.map_err(|err| error!("{}", &err.cause))?;
conf.flush()?;
Expand Down

0 comments on commit 497b721

Please sign in to comment.