From 3759a6695d12abcb7901c82a7b93d184deb55248 Mon Sep 17 00:00:00 2001 From: rchaser53 Date: Sun, 14 Apr 2019 17:34:53 +0900 Subject: [PATCH] add the error mapping --- src/cargo-fmt/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cargo-fmt/main.rs b/src/cargo-fmt/main.rs index 59b76a542792..55f098348b99 100644 --- a/src/cargo-fmt/main.rs +++ b/src/cargo-fmt/main.rs @@ -127,7 +127,14 @@ fn get_version() -> Result { let mut command = Command::new("rustfmt") .stdout(std::process::Stdio::inherit()) .args(&[String::from("--version")]) - .spawn()?; + .spawn() + .map_err(|e| match e.kind() { + io::ErrorKind::NotFound => io::Error::new( + io::ErrorKind::Other, + "Could not run rustfmt, please make sure it is in your PATH.", + ), + _ => e, + })?; status.push(command.wait()?); Ok(status