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

Don't print extra error info for subcommands #2674

Merged
merged 1 commit into from
May 12, 2016
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
22 changes: 14 additions & 8 deletions src/bin/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use std::path::{Path,PathBuf};

use cargo::core::shell::Verbosity;
use cargo::execute_main_without_stdin;
use cargo::util::ChainError;
use cargo::util::{self, CliResult, lev_distance, Config, human, CargoResult};
use cargo::util::{self, CliResult, lev_distance, Config, human};
use cargo::util::CliError;
use cargo::util::process_builder::process;

#[derive(RustcDecodable)]
Expand Down Expand Up @@ -199,7 +199,7 @@ fn find_closest(config: &Config, cmd: &str) -> Option<String> {

fn execute_subcommand(config: &Config,
cmd: &str,
args: &[String]) -> CargoResult<()> {
args: &[String]) -> CliResult<()> {
let command_exe = format!("cargo-{}{}", cmd, env::consts::EXE_SUFFIX);
let path = search_directories(config)
.iter()
Expand All @@ -212,13 +212,19 @@ fn execute_subcommand(config: &Config,
Some(closest) => format!("no such subcommand\n\n\t\
Did you mean `{}`?\n", closest),
None => "no such subcommand".to_string()
}))
}).into())
}
};
try!(util::process(&command).args(&args[1..]).exec().chain_error(|| {
human(format!("third party subcommand `{}` exited unsuccessfully", command_exe))
}));
Ok(())
let err = match util::process(&command).args(&args[1..]).exec() {
Ok(()) => return Ok(()),
Err(e) => e,
};

if let Some(code) = err.exit.as_ref().and_then(|c| c.code()) {
Err(CliError::new("", code))
} else {
Err(CliError::from_error(err, 101))
}
}

/// List all runnable commands. find_command should always succeed
Expand Down
6 changes: 1 addition & 5 deletions tests/test_cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,11 +717,7 @@ test!(reports_unsuccessful_subcommand_result {
assert_that(cargo_process("fail"),
execs().with_status(101).with_stderr_contains("\
thread '<main>' panicked at 'explicit panic', [..]
").with_stderr_contains(format!("\
[ERROR] third party subcommand `cargo-fail[..]` exited unsuccessfully

To learn more, run the command again with --verbose.
")));
"));
});

test!(git_with_lockfile {
Expand Down