mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Provide more context on process errors
When printing an error for a failed process execution, the stdout/stderr are included for inspection.
This commit is contained in:
parent
96ab5d73ff
commit
47d9bf8b4c
@ -143,18 +143,30 @@ impl Show for ProcessError {
|
||||
Some(ExitStatus(i)) | Some(ExitSignal(i)) => i.to_str(),
|
||||
None => "never executed".to_str()
|
||||
};
|
||||
write!(f, "{} (status={})", self.msg, exit)
|
||||
try!(write!(f, "{} (status={})", self.msg, exit));
|
||||
match self.output {
|
||||
Some(ref out) => {
|
||||
match str::from_utf8(out.output.as_slice()) {
|
||||
Some(s) if s.trim().len() > 0 => {
|
||||
try!(write!(f, "\n--- stdout\n{}", s));
|
||||
}
|
||||
Some(..) | None => {}
|
||||
}
|
||||
match str::from_utf8(out.error.as_slice()) {
|
||||
Some(s) if s.trim().len() > 0 => {
|
||||
try!(write!(f, "\n--- stderr\n{}", s));
|
||||
}
|
||||
Some(..) | None => {}
|
||||
}
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl CargoError for ProcessError {
|
||||
fn description(&self) -> String {
|
||||
let exit = match self.exit {
|
||||
Some(ExitStatus(i)) | Some(ExitSignal(i)) => i.to_str(),
|
||||
None => "never executed".to_str()
|
||||
};
|
||||
format!("{} (status={})", self.msg, exit)
|
||||
}
|
||||
fn description(&self) -> String { self.to_str() }
|
||||
|
||||
fn detail(&self) -> Option<String> {
|
||||
self.detail.clone()
|
||||
|
Loading…
x
Reference in New Issue
Block a user