Skip to content

Commit

Permalink
Emit a good error message when a command failed to execute. (#122)
Browse files Browse the repository at this point in the history
I hit this when 'perl' wasn't installed on my windows.
  • Loading branch information
Julian-Wollersberger authored Mar 7, 2022
1 parent 85ef012 commit 8a3f620
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,21 +534,25 @@ impl Build {

fn run_command(&self, mut command: Command, desc: &str) {
println!("running {:?}", command);
let status = command.status().unwrap();
if !status.success() {
panic!(
"
let status = command.status();

let (status_or_failed, error) = match status {
Ok(status) if status.success() => return,
Ok(status) => ("Exit status", format!("{}", status)),
Err(failed) => ("Failed to execute", format!("{}", failed)),
};
panic!(
"
Error {}:
Command: {:?}
Exit status: {}
{}: {}
",
desc, command, status
);
}
desc, command, status_or_failed, error
);
}
}

Expand Down

0 comments on commit 8a3f620

Please sign in to comment.