]> git.lizzy.rs Git - rust.git/commitdiff
Show more helpful error if rustfmt is not in PATH.
authorJohann Hofmann <mail@johann-hofmann.com>
Sat, 2 Jul 2016 20:19:04 +0000 (22:19 +0200)
committerJohann Hofmann <mail@johann-hofmann.com>
Mon, 4 Jul 2016 05:42:18 +0000 (07:42 +0200)
This fixes #1071.

src/bin/cargo-fmt.rs

index 909d62b20f87ed261eab7e44910f4659fa1f3bf9..7bd61dd1661ee811b501052f16bf450c265d85e0 100644 (file)
@@ -204,6 +204,16 @@ fn format_files(files: &Vec<PathBuf>,
         .stdout(stdout)
         .args(files)
         .args(fmt_args)
-        .spawn());
+        .spawn()
+        .map_err(|e| {
+            match e.kind() {
+                std::io::ErrorKind::NotFound => {
+                    std::io::Error::new(std::io::ErrorKind::Other,
+                                        "Could not run rustfmt, please make sure it is in your \
+                                         PATH.")
+                }
+                _ => e,
+            }
+        }));
     command.wait()
 }