diff options
author | Daniel Mueller <deso@posteo.net> | 2019-06-14 18:07:32 -0700 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2019-06-14 18:07:32 -0700 |
commit | e1fc56bf92ab5d93e200e8ac32f197c5fa27846e (patch) | |
tree | 693f5bc24ae539af1fa808e89b6f16c8380a34f8 | |
parent | a83454bcc9cb3f7d10b4ee5926490c80b222430b (diff) | |
download | nitrocli-e1fc56bf92ab5d93e200e8ac32f197c5fa27846e.tar.gz nitrocli-e1fc56bf92ab5d93e200e8ac32f197c5fa27846e.tar.bz2 |
Improve error message when gpg-connect-agent cannot be found
When the gpg-connect-agent binary is not available on the system we
report an error that is really only hinting at the problem and without
knowing internals it is hard to guess what may be wrong:
$ nitrocli pws get 0
> IO error: No such file or directory (os error 2)
This change adjusts the code to make the error less ambiguous and more
to the point.
-rw-r--r-- | nitrocli/src/pinentry.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/nitrocli/src/pinentry.rs b/nitrocli/src/pinentry.rs index d8a77d4..0733cd1 100644 --- a/nitrocli/src/pinentry.rs +++ b/nitrocli/src/pinentry.rs @@ -19,6 +19,7 @@ use std::borrow; use std::fmt; +use std::io; use std::process; use std::str; @@ -263,7 +264,13 @@ where let output = process::Command::new("gpg-connect-agent") .arg(command) .arg("/bye") - .output()?; + .output() + .map_err(|err| match err.kind() { + io::ErrorKind::NotFound => { + io::Error::new(io::ErrorKind::NotFound, "gpg-connect-agent not found") + } + _ => err, + })?; parse_pinentry_pin(str::from_utf8(&output.stdout)?) } |