error: Add stdout to the `Error::Cli` variant

master
Nick Fitzgerald 7 years ago
parent 1621d18072
commit e9276e0aab
  1. 2
      src/child.rs
  2. 9
      src/error.rs

@ -172,6 +172,6 @@ pub fn run(
return Ok(stdout);
} else {
let msg = format!("`{}` did not exit successfully", command_name);
return Err(Error::cli(&msg, stderr.into(), exit).into());
return Err(Error::cli(&msg, stdout.into(), stderr.into(), exit).into());
}
}

@ -48,14 +48,17 @@ pub enum Error {
/// An error invoking another CLI tool.
#[fail(
display = "Process exited with {}: {}. stderr:\n\n{}",
display = "Process exited with {}: {}.\n\nstdout:{}\n\nstderr:\n\n{}",
exit_status,
message,
stdout,
stderr
)]
Cli {
/// Error message.
message: String,
/// The underlying CLI's `stdout` output.
stdout: String,
/// The underlying CLI's `stderr` output.
stderr: String,
/// The exit status of the subprocess
@ -101,9 +104,10 @@ pub enum Error {
impl Error {
/// Construct a CLI error.
pub fn cli(message: &str, stderr: Cow<str>, exit_status: ExitStatus) -> Self {
pub fn cli(message: &str, stdout: Cow<str>, stderr: Cow<str>, exit_status: ExitStatus) -> Self {
Error::Cli {
message: message.to_string(),
stdout: stdout.to_string(),
stderr: stderr.to_string(),
exit_status,
}
@ -161,6 +165,7 @@ impl Error {
} => "Your rustc version is not supported. Please install version 1.30.0 or higher.",
Error::Cli {
message: _,
stdout: _,
stderr: _,
exit_status: _,
} => "There was an error while calling another CLI tool. Details:\n\n",

Loading…
Cancel
Save