Skip to content

Commit

Permalink
build(proto): be more verbose on errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aelesbao committed Oct 13, 2023
1 parent cd73ebc commit 31ddb08
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/proto/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ fn run_cmd(
cmd: impl AsRef<OsStr>,
args: impl IntoIterator<Item = impl AsRef<OsStr>>,
) -> Result<String> {
let process::Output { stdout, status, .. } = process::Command::new(&cmd)
let process::Output {
stdout,
stderr,
status,
} = process::Command::new(&cmd)
.args(args)
.output()
.unwrap_or_else(|e| match e.kind() {
Expand All @@ -134,14 +138,17 @@ fn run_cmd(
_ => panic!("error running '{:?}': {:?}", cmd.as_ref(), e),
});

let output = std::str::from_utf8(&stdout)?.trim();
if !status.success() {
let error = std::str::from_utf8(&stderr)?.trim();
panic!(
"{:?} exited with error code: {:?}",
"{:?} exited with error code: {:?}\nstdout: {:?}\nstderr: {:?}",
cmd.as_ref(),
status.code()
status.code().unwrap_or(-1),
output,
error
);
}

let output = std::str::from_utf8(&stdout)?.trim();
Ok(output.to_string())
}

0 comments on commit 31ddb08

Please sign in to comment.