From e53a2981b002c31c51c65f07d2430e04457bc270 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Fri, 16 Apr 2021 22:45:15 -0700 Subject: [PATCH] Change error formatting to omit backtraces The format specifier we use for printing errors returned by the main program will include a backtrace in the output -- if one is available. That's not necessarily a feature that we need: the causal chain of errors should be sufficient and end users are unlikely to have use for a backtrace. This change adjusts the format specifier so that we only print the chain of errors, albeit in a slightly different format: - Previously: > Failed to generate OTP > > Caused by: > Command error: The given slot is not programmed - New: > Failed to generate OTP: Command error: The given slot is not programmed --- CHANGELOG.md | 1 + src/main.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b614808..03d55eff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Unreleased - Introduced extension support crate, `nitrocli-ext` - Introduced `otp-cache` core extension - Enabled usage of empty PWS slot fields +- Changed error reporting format to make up only a single line - Added `NITROCLI_RESOLVED_USB_PATH` environment variable to be used by extensions - Allowed entering of `base32` encoded strings containing spaces diff --git a/src/main.rs b/src/main.rs index a2e0a872..9a5ee4df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -233,7 +233,7 @@ fn evaluate_err(err: anyhow::Error, stderr: &mut dyn io::Write) -> i32 { if let Some(err) = err.root_cause().downcast_ref::() { err.0 } else { - let _ = writeln!(stderr, "{:?}", err); + let _ = writeln!(stderr, "{:#}", err); 1 } }