aboutsummaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs
index 89c4c82..3f60af2 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -9,6 +9,8 @@ use std::result;
pub enum Error {
/// An error reported by the Nitrokey device in the response packet.
CommandError(CommandError),
+ /// Placeholder for testing.
+ CommunicationError(CommunicationError),
}
impl From<CommandError> for Error {
@@ -21,6 +23,7 @@ impl error::Error for Error {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match *self {
Error::CommandError(ref err) => Some(err),
+ Error::CommunicationError(_) => None,
}
}
}
@@ -29,6 +32,7 @@ impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Error::CommandError(ref err) => write!(f, "Command error: {}", err),
+ Error::CommunicationError(_) => write!(f, "Placeholder"),
}
}
}
@@ -78,6 +82,13 @@ pub enum CommandError {
RngError,
}
+/// Placeholder for testing.
+#[derive(Debug)]
+pub enum CommunicationError {
+ /// Placeholder for testing.
+ NotConnected,
+}
+
impl CommandError {
fn as_str(&self) -> borrow::Cow<'static, str> {
match *self {