From 31ddb0841d945dbd403f01f64b794aa8ee5a316b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Augusto=20Elesb=C3=A3o?= Date: Fri, 13 Oct 2023 10:53:13 +0200 Subject: [PATCH] build(proto): be more verbose on errors --- packages/proto/build.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/proto/build.rs b/packages/proto/build.rs index 22e8788..9eb12a6 100644 --- a/packages/proto/build.rs +++ b/packages/proto/build.rs @@ -123,7 +123,11 @@ fn run_cmd( cmd: impl AsRef, args: impl IntoIterator>, ) -> Result { - 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() { @@ -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()) }