diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2019-12-30 10:53:54 +0100 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2020-01-07 11:33:04 +0100 |
commit | ddb175bd963070e837aa9207c2dee32ffffc51f4 (patch) | |
tree | 699f93ff5d6bfd74bf3218b7a0d8dc725c54f7c7 /src | |
parent | e0baabd1046087a9f545d9ef65539c23eb91e85f (diff) | |
download | nitrokey-rs-ddb175bd963070e837aa9207c2dee32ffffc51f4.tar.gz nitrokey-rs-ddb175bd963070e837aa9207c2dee32ffffc51f4.tar.bz2 |
Add the Error::UnsupportedModelError variant
This patch adds the UnsupportedModelError variant to the Error enum:
When parsing the model returned by libnitrokey, we should provide a
meaningful error message for unknown values.
Diffstat (limited to 'src')
-rw-r--r-- | src/error.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs index 9e6adc0..f9af594 100644 --- a/src/error.rs +++ b/src/error.rs @@ -28,6 +28,8 @@ pub enum Error { UnexpectedError, /// An unknown error returned by libnitrokey. UnknownError(i64), + /// An error caused by a Nitrokey model that is not supported by this crate. + UnsupportedModelError, /// An error occurred when interpreting a UTF-8 string. Utf8Error(str::Utf8Error), } @@ -102,6 +104,7 @@ impl error::Error for Error { Error::RandError(ref err) => Some(err.as_ref()), Error::UnexpectedError => None, Error::UnknownError(_) => None, + Error::UnsupportedModelError => None, Error::Utf8Error(ref err) => Some(err), } } @@ -118,6 +121,7 @@ impl fmt::Display for Error { Error::RandError(ref err) => write!(f, "RNG error: {}", err), Error::UnexpectedError => write!(f, "An unexpected error occurred"), 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), } } |