Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 3759a66

Browse files
committed
add the error mapping
1 parent 8a04ec6 commit 3759a66

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/cargo-fmt/main.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,14 @@ fn get_version() -> Result<i32, io::Error> {
127127
let mut command = Command::new("rustfmt")
128128
.stdout(std::process::Stdio::inherit())
129129
.args(&[String::from("--version")])
130-
.spawn()?;
130+
.spawn()
131+
.map_err(|e| match e.kind() {
132+
io::ErrorKind::NotFound => io::Error::new(
133+
io::ErrorKind::Other,
134+
"Could not run rustfmt, please make sure it is in your PATH.",
135+
),
136+
_ => e,
137+
})?;
131138
status.push(command.wait()?);
132139

133140
Ok(status

0 commit comments

Comments
 (0)