]> git.proxmox.com Git - cargo.git/commitdiff
Use handle_error instead of shell.error to print stack trace if in verbose
authordgellow <samuel.elborai@gmail.com>
Wed, 25 Jan 2017 19:06:08 +0000 (20:06 +0100)
committerdgellow <samuel.elborai@gmail.com>
Wed, 25 Jan 2017 19:06:15 +0000 (20:06 +0100)
src/cargo/lib.rs
src/cargo/ops/cargo_rustc/job_queue.rs

index 46daa9441e7d8c96758cbfec253c69dc86939fa9..539fd8c348b59d1b617a261356679a082a1cc0a4 100644 (file)
@@ -96,7 +96,7 @@ pub fn process_executed<T>(result: CliResult<Option<T>>, 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);
     }
 }
 
index a72b6e1f9b2d05fab9fdf69e456c27a245c7248f..e7a242c55173c1dc5bb8aab3fb6c341b14ac5c87 100644 (file)
@@ -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 \