From e1fc56bf92ab5d93e200e8ac32f197c5fa27846e Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Fri, 14 Jun 2019 18:07:32 -0700 Subject: 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. --- nitrocli/src/pinentry.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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)?) } -- cgit v1.2.1