From b4bd00fdad094b16c785b8ead9f92d68264f5fb4 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 12 Feb 2019 17:51:26 -0800 Subject: error: Print errors using Display impl I have been running into Debug-printed error messages too often and needing to look up in the source code each level of nested errors to find out from the comment on the error variant what the short name of the variant means in human terms. Worse, many errors (like the one shown below) already had error strings written but were being printed from the calling code in the less helpful Debug representation anyway. Before: [ERROR:src/main.rs:705] The architecture failed to build the vm: NoVarEmpty After: [ERROR:src/main.rs:705] The architecture failed to build the vm: /var/empty doesn't exist, can't jail devices. TEST=cargo check --all-features TEST=FEATURES=test emerge-amd64-generic crosvm Change-Id: I77122c7d6861b2d610de2fff718896918ab21e10 Reviewed-on: https://chromium-review.googlesource.com/1469225 Commit-Ready: David Tolnay Tested-by: David Tolnay Tested-by: kokoro Reviewed-by: Daniel Verkamp --- src/plugin/process.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/plugin/process.rs') diff --git a/src/plugin/process.rs b/src/plugin/process.rs index 2f3560d..2df9284 100644 --- a/src/plugin/process.rs +++ b/src/plugin/process.rs @@ -412,7 +412,7 @@ impl Process { if cpu_mask & (1 << cpu_id) != 0 { per_cpu_state.lock().request_pause(user_data); if let Err(e) = handle.kill(SIGRTMIN() + 0) { - error!("failed to interrupt vcpu {}: {:?}", cpu_id, e); + error!("failed to interrupt vcpu {}: {}", cpu_id, e); } } } @@ -425,7 +425,7 @@ impl Process { // Log any NetError so that the cause can be found later, but extract and return the // underlying errno for the client as well. fn map_net_error(s: &str, e: NetError) -> SysError { - error!("failed to get {}: {:?}", s, e); + error!("failed to get {}: {}", s, e); e.sys_error() } @@ -683,7 +683,7 @@ impl Drop for Process { fn drop(&mut self) { // Ignore the result because there is nothing we can do about it. if let Err(e) = self.signal_kill() { - error!("failed to signal kill event for plugin: {:?}", e); + error!("failed to signal kill event for plugin: {}", e); } } } -- cgit 1.4.1