Merge pull request #424 from fitzgen/issue-422

Issue 422
master
Nick Fitzgerald 7 years ago committed by GitHub
commit df4ef1f451
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/build.rs
  2. 3
      src/child.rs
  3. 13
      src/error.rs
  4. 2
      src/main.rs

@ -82,7 +82,7 @@ pub fn cargo_build_wasm(
cmd.arg("--release"); cmd.arg("--release");
} }
cmd.arg("--target").arg("wasm32-unknown-unknown"); cmd.arg("--target").arg("wasm32-unknown-unknown");
child::run(log, cmd, "cargo build").context("Compiling your crate to WebAssembly")?; child::run(log, cmd, "cargo build").context("Compiling your crate to WebAssembly failed")?;
Ok(()) Ok(())
} }

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

@ -47,13 +47,10 @@ pub enum Error {
}, },
/// An error invoking another CLI tool. /// An error invoking another CLI tool.
#[fail( #[fail(display = "`{}` exited with {}", tool, exit_status)]
display = "Process exited with {}: {}.\n\nstdout:{}\n\nstderr:\n\n{}",
exit_status, message, stdout, stderr
)]
Cli { Cli {
/// Error message. /// Error message.
message: String, tool: String,
/// The underlying CLI's `stdout` output. /// The underlying CLI's `stdout` output.
stdout: String, stdout: String,
/// The underlying CLI's `stderr` output. /// The underlying CLI's `stderr` output.
@ -101,9 +98,9 @@ pub enum Error {
impl Error { impl Error {
/// Construct a CLI error. /// Construct a CLI error.
pub fn cli(message: &str, stdout: Cow<str>, stderr: Cow<str>, exit_status: ExitStatus) -> Self { pub fn cli(tool: &str, stdout: Cow<str>, stderr: Cow<str>, exit_status: ExitStatus) -> Self {
Error::Cli { Error::Cli {
message: message.to_string(), tool: tool.to_string(),
stdout: stdout.to_string(), stdout: stdout.to_string(),
stderr: stderr.to_string(), stderr: stderr.to_string(),
exit_status, exit_status,
@ -161,7 +158,7 @@ impl Error {
local_minor_version: _, local_minor_version: _,
} => "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: _, tool: _,
stdout: _, stdout: _,
stderr: _, stderr: _,
exit_status: _, exit_status: _,

@ -16,7 +16,7 @@ mod installer;
fn main() { fn main() {
setup_panic!(); setup_panic!();
if let Err(e) = run() { if let Err(e) = run() {
eprintln!("{}", e); eprintln!("Error: {}", e);
for cause in e.iter_causes() { for cause in e.iter_causes() {
eprintln!("Caused by: {}", cause); eprintln!("Caused by: {}", cause);
} }

Loading…
Cancel
Save