From 59ba386bee974b56b546eb7e8fdec6721ab0d08a Mon Sep 17 00:00:00 2001 From: veetaha Date: Wed, 18 Mar 2020 22:49:14 +0200 Subject: ra_cargo_watch: log more errors --- crates/ra_cargo_watch/src/lib.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/crates/ra_cargo_watch/src/lib.rs b/crates/ra_cargo_watch/src/lib.rs index bffe5eb00..deb763af9 100644 --- a/crates/ra_cargo_watch/src/lib.rs +++ b/crates/ra_cargo_watch/src/lib.rs @@ -259,7 +259,7 @@ pub fn run_cargo( let mut child = command .args(args) .stdout(Stdio::piped()) - .stderr(Stdio::null()) + .stderr(Stdio::piped()) .stdin(Stdio::null()) .spawn() .expect("couldn't launch cargo"); @@ -352,8 +352,21 @@ impl WatchThread { // It is okay to ignore the result, as it only errors if the process is already dead let _ = child.kill(); - // Again, we don't care about the exit status so just ignore the result - let _ = child.wait(); + // Again, we are resilient to errors, so we don't try to panic here + match child.wait_with_output() { + Ok(output) => match output.status.code() { + Some(0) | None => {} + Some(exit_code) => { + let output = + std::str::from_utf8(&output.stderr).unwrap_or(""); + + if !output.contains("could not compile") { + log::error!("Cargo failed with exit code {} {}", exit_code, output); + } + } + }, + Err(err) => log::error!("Cargo io error: {:?}", err), + } })) } else { None -- cgit v1.2.3