diff --git a/sim-cli/src/main.rs b/sim-cli/src/main.rs index f88aa2a1..0aa5ff05 100644 --- a/sim-cli/src/main.rs +++ b/sim-cli/src/main.rs @@ -114,17 +114,17 @@ async fn main() -> anyhow::Result<()> { ); if clients.contains_key(&node_info.pubkey) { - anyhow::bail!(LightningError::ValidationError(format!( - "duplicated node: {}.", - node_info.pubkey - ))); + anyhow::bail!( + "Lightning Error\nCaused by: {}", + LightningError::ValidationError(format!("duplicated node: {}.", node_info.pubkey)) + ); } if alias_node_map.contains_key(&node_info.alias) { - anyhow::bail!(LightningError::ValidationError(format!( - "duplicated node: {}.", - node_info.alias - ))); + anyhow::bail!( + "Lightning Error\nCaused by: {}", + LightningError::ValidationError(format!("duplicated node: {}.", node_info.alias)) + ); } clients.insert(node_info.pubkey, node); @@ -143,10 +143,13 @@ async fn main() -> anyhow::Result<()> { } { source.clone() } else { - anyhow::bail!(LightningError::ValidationError(format!( - "activity source {} not found in nodes.", - act.source - ))); + anyhow::bail!( + "Lightning Error\nCaused by: {}", + LightningError::ValidationError(format!( + "activity source {} not found in nodes.", + act.source + )) + ); }; let destination = match &act.destination { @@ -154,10 +157,13 @@ async fn main() -> anyhow::Result<()> { if let Some(info) = alias_node_map.get(a) { info.clone() } else { - anyhow::bail!(LightningError::ValidationError(format!( - "unknown activity destination: {}.", - act.destination - ))); + anyhow::bail!( + "Lightning Error\nCaused by: {}", + LightningError::ValidationError(format!( + "unknown activity destination: {}.", + act.destination + )) + ); } }, NodeId::PublicKey(pk) => { @@ -174,7 +180,7 @@ async fn main() -> anyhow::Result<()> { .map_err(|e| { log::debug!("{}", e); LightningError::ValidationError(format!( - "Destination node unknown or invalid: {}.", + "Lightning Error\nDestination node unknown or invalid: {}.", pk, )) })? diff --git a/sim-lib/src/lib.rs b/sim-lib/src/lib.rs index 116d491e..9778471f 100644 --- a/sim-lib/src/lib.rs +++ b/sim-lib/src/lib.rs @@ -171,7 +171,7 @@ pub struct ActivityDefinition { #[derive(Debug, Error)] pub enum SimulationError { - #[error("Lightning Error: {0:?}")] + #[error("Lightning Error")] LightningError(#[from] LightningError), #[error("TaskError")] TaskError, @@ -195,19 +195,19 @@ pub enum SimulationError { #[derive(Debug, Error)] pub enum LightningError { - #[error("Node connection error: {0}")] + #[error("Node connection error\nCaused by: {0}")] ConnectionError(String), - #[error("Get info error: {0}")] + #[error("Get info error\n{0}")] GetInfoError(String), - #[error("Send payment error: {0}")] + #[error("Send payment error\n{0}")] SendPaymentError(String), - #[error("Track payment error: {0}")] + #[error("Track payment error\n{0}")] TrackPaymentError(String), #[error("Invalid payment hash")] InvalidPaymentHash, - #[error("Get node info error: {0}")] + #[error("Get node info error\n{0}")] GetNodeInfoError(String), - #[error("Config validation failed: {0}")] + #[error("Config validation failed {0}")] ValidationError(String), #[error("Permanent error: {0:?}")] PermanentError(String), @@ -466,7 +466,7 @@ impl Simulation { let node = node.lock().await; if !node.get_info().features.supports_keysend() { return Err(LightningError::ValidationError(format!( - "All nodes eligible for random activity generation must support keysend, {} does not", + "All nodes eligible for random activity generation must support keysend,\n{} does not", node.get_info() ))); } diff --git a/sim-lib/src/random_activity.rs b/sim-lib/src/random_activity.rs index f8a50e75..31a48c14 100644 --- a/sim-lib/src/random_activity.rs +++ b/sim-lib/src/random_activity.rs @@ -13,7 +13,7 @@ const SECONDS_PER_MONTH: u64 = HOURS_PER_MONTH * 60 * 60; #[derive(Debug, Error)] pub enum RandomActivityError { - #[error("Value error: {0}")] + #[error("Value error\nCaused by: {0}")] ValueError(String), #[error("InsufficientCapacity: {0}")] InsufficientCapacity(String),