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); return Ok(stdout);
} else { } else {
let msg = format!("`{}` did not exit successfully", command_name); 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. /// An error invoking another CLI tool.
#[fail( #[fail(
display = "Process exited with {}: {}. stderr:\n\n{}", display = "Process exited with {}: {}.\n\nstdout:{}\n\nstderr:\n\n{}",
exit_status, exit_status,
message, message,
stdout,
stderr stderr
)] )]
Cli { Cli {
/// Error message. /// Error message.
message: String, message: String,
/// The underlying CLI's `stdout` output.
stdout: String,
/// The underlying CLI's `stderr` output. /// The underlying CLI's `stderr` output.
stderr: String, stderr: String,
/// The exit status of the subprocess /// The exit status of the subprocess
@ -101,9 +104,10 @@ pub enum Error {
impl Error { impl Error {
/// Construct a CLI 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 { Error::Cli {
message: message.to_string(), message: message.to_string(),
stdout: stdout.to_string(),
stderr: stderr.to_string(), stderr: stderr.to_string(),
exit_status, exit_status,
} }
@ -161,6 +165,7 @@ impl Error {
} => "Your rustc version is not supported. Please install version 1.30.0 or higher.", } => "Your rustc version is not supported. Please install version 1.30.0 or higher.",
Error::Cli { Error::Cli {
message: _, message: _,
stdout: _,
stderr: _, stderr: _,
exit_status: _, exit_status: _,
} => "There was an error while calling another CLI tool. Details:\n\n", } => "There was an error while calling another CLI tool. Details:\n\n",

Loading…
Cancel
Save