From 592d1a55f0c05c1dcba58261f327066b4832a703 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Fri, 28 Aug 2020 18:44:45 -0700 Subject: Use anyhow for error handling This patch changes our error handling approach from the ground up: instead of having a globally used Error enum that contains variants for all possible errors, we now use anyhow's Error type. This approach is more dynamic (and not statically typed), but it allows for more fine grained error messages and overall more user-friendly error reporting. Overall it also is a net simplification. While we have one dynamic cast now, in order to be able to handle erroneous password/PIN entries correctly, that is considered a reasonable compromise. --- src/tests/status.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/tests/status.rs') diff --git a/src/tests/status.rs b/src/tests/status.rs index e80fadc..c617a9e 100644 --- a/src/tests/status.rs +++ b/src/tests/status.rs @@ -19,15 +19,18 @@ use super::*; -// This test acts as verification that conversion of Error::Error -// variants into the proper exit code works properly. #[test_device] fn not_found_raw() { let (rc, out, err) = Nitrocli::new().run(&["status"]); assert_ne!(rc, 0); assert_eq!(out, b""); - assert_eq!(err, b"Nitrokey device not found\n"); + let expected = r#"Nitrokey device not found + +Caused by: + Communication error: Could not connect to a Nitrokey device +"#; + assert_eq!(err, expected.as_bytes()); } #[test_device] -- cgit v1.2.1