aboutsummaryrefslogtreecommitdiff
path: root/src/device.rs
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2019-01-02 15:53:18 -0800
committerRobin Krahl <robin.krahl@ireas.org>2019-01-03 02:12:17 +0100
commit65ead1426e1e9864b7e245fd729a66e689e549b4 (patch)
treea93c39fdd5e2b1240d8df3beea69b8335e9b5941 /src/device.rs
parent60a976fb7f721b800ba145a9bd5b416c6d3de834 (diff)
downloadnitrokey-rs-65ead1426e1e9864b7e245fd729a66e689e549b4.tar.gz
nitrokey-rs-65ead1426e1e9864b7e245fd729a66e689e549b4.tar.bz2
Preserve unknown error code values
The CommandError::Unknown variant, which is used whenever a reported error code is not known, makes it close to impossible to determine the root cause of, say, a one-off error, because all information explaining what went wrong is discarded. With this change we adjust the Unknown variant to include the error report. In addition, we introduce a new CommandError variant, Undefined, that is used when no error code is available.
Diffstat (limited to 'src/device.rs')
-rw-r--r--src/device.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/device.rs b/src/device.rs
index 9c6608d..33e5410 100644
--- a/src/device.rs
+++ b/src/device.rs
@@ -532,9 +532,9 @@ pub fn connect() -> Result<DeviceWrapper, CommandError> {
match nitrokey_sys::NK_login_auto() {
1 => match get_connected_device() {
Some(wrapper) => Ok(wrapper),
- None => Err(CommandError::Unknown),
+ None => Err(CommandError::Undefined),
},
- _ => Err(CommandError::Unknown),
+ _ => Err(CommandError::Undefined),
}
}
}
@@ -623,7 +623,7 @@ impl Pro {
// TODO: maybe Option instead of Result?
match connect_model(Model::Pro) {
true => Ok(Pro {}),
- false => Err(CommandError::Unknown),
+ false => Err(CommandError::Undefined),
}
}
}
@@ -663,7 +663,7 @@ impl Storage {
// TODO: maybe Option instead of Result?
match connect_model(Model::Storage) {
true => Ok(Storage {}),
- false => Err(CommandError::Unknown),
+ false => Err(CommandError::Undefined),
}
}