summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-01-28 10:07:23 +0100
committerRobin Krahl <robin.krahl@ireas.org>2020-01-28 11:54:20 +0100
commitda8727996efacec4280696caefee3feecea4eae7 (patch)
tree82f410d4009b698b630a90bcfa6255c07d743a33 /src/error.rs
parent47795368c32c0c47a9c3da761c3adf0a36ca419f (diff)
downloadnitrokey-rs-da8727996efacec4280696caefee3feecea4eae7.tar.gz
nitrokey-rs-da8727996efacec4280696caefee3feecea4eae7.tar.bz2
Add String value to the Error::UnexpectedError variant
To make debugging of unexpected errors easier, this patch adds an associated String value with a description of the unexpected behavior to the UnexpectedError variant of the Error enum.
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/error.rs b/src/error.rs
index f9af594..7bea3f2 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -25,7 +25,7 @@ pub enum Error {
/// An error that occurred during random number generation.
RandError(Box<dyn error::Error>),
/// An error that is caused by an unexpected value returned by libnitrokey.
- UnexpectedError,
+ UnexpectedError(String),
/// An unknown error returned by libnitrokey.
UnknownError(i64),
/// An error caused by a Nitrokey model that is not supported by this crate.
@@ -102,7 +102,7 @@ impl error::Error for Error {
Error::LibraryError(ref err) => Some(err),
Error::PoisonError(ref err) => Some(err),
Error::RandError(ref err) => Some(err.as_ref()),
- Error::UnexpectedError => None,
+ Error::UnexpectedError(_) => None,
Error::UnknownError(_) => None,
Error::UnsupportedModelError => None,
Error::Utf8Error(ref err) => Some(err),
@@ -119,7 +119,7 @@ impl fmt::Display for Error {
Error::LibraryError(ref err) => write!(f, "Library error: {}", err),
Error::PoisonError(_) => write!(f, "Internal error: poisoned lock"),
Error::RandError(ref err) => write!(f, "RNG error: {}", err),
- Error::UnexpectedError => write!(f, "An unexpected error occurred"),
+ Error::UnexpectedError(ref s) => write!(f, "An unexpected error occurred: {}", s),
Error::UnknownError(ref err) => write!(f, "Unknown error: {}", err),
Error::UnsupportedModelError => write!(f, "Unsupported Nitrokey model"),
Error::Utf8Error(ref err) => write!(f, "UTF-8 error: {}", err),