Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 422 #424

Merged
merged 3 commits into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub fn cargo_build_wasm(
cmd.arg("--release");
}
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(())
}

Expand Down
3 changes: 1 addition & 2 deletions src/child.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ pub fn run(
if exit.success() {
return Ok(stdout);
} else {
let msg = format!("`{}` did not exit successfully", command_name);
return Err(Error::cli(&msg, stdout.into(), stderr.into(), exit).into());
return Err(Error::cli(command_name, stdout.into(), stderr.into(), exit).into());
}
}
13 changes: 5 additions & 8 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,10 @@ pub enum Error {
},

/// An error invoking another CLI tool.
#[fail(
display = "Process exited with {}: {}.\n\nstdout:{}\n\nstderr:\n\n{}",
exit_status, message, stdout, stderr
)]
#[fail(display = "`{}` exited with {}", tool, exit_status)]
Cli {
/// Error message.
message: String,
tool: String,
/// The underlying CLI's `stdout` output.
stdout: String,
/// The underlying CLI's `stderr` output.
Expand Down Expand Up @@ -101,9 +98,9 @@ pub enum Error {

impl 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 {
message: message.to_string(),
tool: tool.to_string(),
stdout: stdout.to_string(),
stderr: stderr.to_string(),
exit_status,
Expand Down Expand Up @@ -161,7 +158,7 @@ impl Error {
local_minor_version: _,
} => "Your rustc version is not supported. Please install version 1.30.0 or higher.",
Error::Cli {
message: _,
tool: _,
stdout: _,
stderr: _,
exit_status: _,
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod installer;
fn main() {
setup_panic!();
if let Err(e) = run() {
eprintln!("{}", e);
eprintln!("Error: {}", e);
for cause in e.iter_causes() {
eprintln!("Caused by: {}", cause);
}
Expand Down