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 } } diff --git a/src/tests/otp.rs b/src/tests/otp.rs index 8a48adb8..26d8c662 100644 --- a/src/tests/otp.rs +++ b/src/tests/otp.rs @@ -7,6 +7,18 @@ use super::*; use crate::args; +#[test_device] +fn error_format(model: nitrokey::Model) { + let (rc, out, err) = Nitrocli::new().model(model).run(&["otp", "get", "32"]); + + assert_ne!(rc, 0); + assert_eq!(out, b"", "{}", String::from_utf8_lossy(&out)); + assert_eq!( + err, + b"Failed to generate OTP: Library error: The given slot is invalid\n" + ); +} + #[test_device] fn set_invalid_slot_raw(model: nitrokey::Model) { let (rc, out, err) = Nitrocli::new()