From: dgellow Date: Wed, 25 Jan 2017 19:06:08 +0000 (+0100) Subject: Use handle_error instead of shell.error to print stack trace if in verbose X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=4c54520d3e231282c5ea8e50d3b30b4283e3ea97;p=cargo.git Use handle_error instead of shell.error to print stack trace if in verbose --- diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 46daa9441..539fd8c34 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -96,7 +96,7 @@ pub fn process_executed(result: CliResult>, shell: &mut MultiShell) where T: Encodable { match result { - Err(e) => handle_error(e, shell), + Err(e) => handle_cli_error(e, shell), Ok(Some(encodable)) => { let encoded = json::encode(&encodable).unwrap(); println!("{}", encoded); @@ -150,8 +150,8 @@ pub fn shell(verbosity: Verbosity, color_config: ColorConfig) -> MultiShell { } } -pub fn handle_error(err: CliError, shell: &mut MultiShell) { - debug!("handle_error; err={:?}", err); +pub fn handle_cli_error(err: CliError, shell: &mut MultiShell) { + debug!("handle_cli_error; err={:?}", err); let CliError { error, exit_code, unknown } = err; // exit_code == 0 is non-fatal error, e.g. docopt version info @@ -177,6 +177,13 @@ pub fn handle_error(err: CliError, shell: &mut MultiShell) { std::process::exit(exit_code); } +pub fn handle_error(err: &CargoError, shell: &mut MultiShell) { + debug!("handle_error; err={:?}", err); + + let _ignored_result = shell.error(err); + handle_cause(err, shell); +} + fn handle_cause(mut cargo_err: &CargoError, shell: &mut MultiShell) -> bool { let verbose = shell.get_verbose(); let mut err; @@ -197,7 +204,7 @@ fn handle_cause(mut cargo_err: &CargoError, shell: &mut MultiShell) -> bool { fn print(error: String, shell: &mut MultiShell) { let _ = shell.err().say("\nCaused by:", BLACK); - let _ = shell.err().say(format!(" {}", error), BLACK); + let _ = shell.err().say(format!(" {}\n", error), BLACK); } } diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index a72b6e1f9..e7a242c55 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -10,6 +10,7 @@ use term::color::YELLOW; use core::{PackageId, Target, Profile}; use util::{Config, DependencyQueue, Fresh, Dirty, Freshness}; use util::{CargoResult, ProcessBuilder, profile, internal, human}; +use {handle_error}; use super::{Context, Kind, Unit}; use super::job::Job; @@ -181,7 +182,8 @@ impl<'a> JobQueue<'a> { match result { Ok(()) => self.finish(key, cx)?, Err(e) => { - cx.config.shell().error(format!("{}", e))?; + handle_error(&*e, &mut *cx.config.shell()); + if self.active > 0 { cx.config.shell().say( "Build failed, waiting for other \