Skip to content

Commit 84c8273

Browse files
Improve error reporting by printing 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 <[email protected]>
1 parent f1621fa commit 84c8273

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cli/src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ fn main() {
3737
// This code just captures any errors.
3838
if let Err(e) = run() {
3939
tracing::error!("{:#}", e);
40+
e.chain().skip(1).enumerate().for_each(|(idx, error)| {
41+
if let Some(e) = error.source() {
42+
eprintln!("{idx}: {e:#?}",)
43+
}
44+
});
4045
std::process::exit(1);
4146
}
4247
}

0 commit comments

Comments
 (0)