From 8334b65d837f14ff990ef6c229db08c8e0699fcf Mon Sep 17 00:00:00 2001 From: Pragyan Poudyal Date: Wed, 16 Apr 2025 10:53:16 +0530 Subject: [PATCH] cli: Print error chain sources Currently only the top level error is printed which makes it hard to pinpoint the origin of the error, this patch prints the error chain similar to a backtrace. Signed-off-by: Pragyan Poudyal --- cli/src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cli/src/main.rs b/cli/src/main.rs index d9429aa33..c5829a3bf 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -37,6 +37,11 @@ fn main() { // This code just captures any errors. if let Err(e) = run() { tracing::error!("{:#}", e); + e.chain().skip(1).enumerate().for_each(|(idx, error)| { + if let Some(e) = error.source() { + eprintln!("{idx}: {e:#?}",) + } + }); std::process::exit(1); } }