Skip to content

Commit

Permalink
Prominently display name of the failing command
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Sep 17, 2024
1 parent 520c2cf commit 7a49e98
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,23 +637,25 @@ impl Build {
println!("running {:?}", command);
let status = command.status();

let (status_or_failed, error) = match status {
let verbose_error = match status {
Ok(status) if status.success() => return,
Ok(status) => ("Exit status", format!("{}", status)),
Err(failed) => ("Failed to execute", format!("{}", failed)),
Ok(status) => format!("'{exe}' reported failure with {status}", exe = command.get_program().to_string_lossy()),
Err(failed) => match failed.kind() {
std::io::ErrorKind::NotFound => format!("Command '{exe}' not found. Is {exe} installed?", exe = command.get_program().to_string_lossy()),
_ => format!("Could not run '{exe}', because {failed}", exe = command.get_program().to_string_lossy()),
}
};
println!("cargo:warning={desc}: {verbose_error}");
panic!(
"
Error {}:
Command: {:?}
{}: {}
Error {desc}:
{verbose_error}
Command failed: {command:?}
",
desc, command, status_or_failed, error
);
");
}
}

Expand Down

0 comments on commit 7a49e98

Please sign in to comment.