Skip to content

Commit 59ba386

Browse files
committed
ra_cargo_watch: log more errors
1 parent fdb12f3 commit 59ba386

File tree

1 file changed

+16
-3
lines changed
  • crates/ra_cargo_watch/src

1 file changed

+16
-3
lines changed

crates/ra_cargo_watch/src/lib.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ pub fn run_cargo(
259259
let mut child = command
260260
.args(args)
261261
.stdout(Stdio::piped())
262-
.stderr(Stdio::null())
262+
.stderr(Stdio::piped())
263263
.stdin(Stdio::null())
264264
.spawn()
265265
.expect("couldn't launch cargo");
@@ -352,8 +352,21 @@ impl WatchThread {
352352
// It is okay to ignore the result, as it only errors if the process is already dead
353353
let _ = child.kill();
354354

355-
// Again, we don't care about the exit status so just ignore the result
356-
let _ = child.wait();
355+
// Again, we are resilient to errors, so we don't try to panic here
356+
match child.wait_with_output() {
357+
Ok(output) => match output.status.code() {
358+
Some(0) | None => {}
359+
Some(exit_code) => {
360+
let output =
361+
std::str::from_utf8(&output.stderr).unwrap_or("<bad utf8 output>");
362+
363+
if !output.contains("could not compile") {
364+
log::error!("Cargo failed with exit code {} {}", exit_code, output);
365+
}
366+
}
367+
},
368+
Err(err) => log::error!("Cargo io error: {:?}", err),
369+
}
357370
}))
358371
} else {
359372
None

0 commit comments

Comments
 (0)