aboutsummaryrefslogtreecommitdiff
path: root/nitrocli/src/commands.rs
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2019-07-14 15:53:25 -0700
committerDaniel Mueller <deso@posteo.net>2019-07-14 15:53:25 -0700
commit8cebc05e924c3b6c927a939bd45862a6ddf6edef (patch)
tree070658a3170a63121e18d5cc7fa2a8a2194685d6 /nitrocli/src/commands.rs
parentba80a9087cc2ca91e81fdb9427213421567419ea (diff)
downloadnitrocli-8cebc05e924c3b6c927a939bd45862a6ddf6edef.tar.gz
nitrocli-8cebc05e924c3b6c927a939bd45862a6ddf6edef.tar.bz2
Include Nitrokey model in error message when no device is found
For functionality that explicitly works with the storage device we emit an error message stating that a "Nitrokey Storage" device could not be found. When the user chooses the model using the -m/--model argument that is not the case. With this patch we adjust the error message printed.
Diffstat (limited to 'nitrocli/src/commands.rs')
-rw-r--r--nitrocli/src/commands.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/nitrocli/src/commands.rs b/nitrocli/src/commands.rs
index 208a0ec..583870b 100644
--- a/nitrocli/src/commands.rs
+++ b/nitrocli/src/commands.rs
@@ -62,10 +62,12 @@ fn get_device(ctx: &mut args::ExecCtx<'_>) -> Result<nitrokey::DeviceWrapper> {
set_log_level(ctx);
match ctx.model {
- Some(model) => nitrokey::connect_model(model.into()),
- None => nitrokey::connect(),
+ Some(model) => nitrokey::connect_model(model.into()).map_err(|_| {
+ let error = format!("Nitrokey {} device not found", model.as_user_facing_str());
+ Error::Error(error)
+ }),
+ None => nitrokey::connect().map_err(|_| Error::from("Nitrokey device not found")),
}
- .map_err(|_| Error::from("Nitrokey device not found"))
}
/// Connect to a Nitrokey Storage device and return it.