From 7d7577007a171b8d299ce6e91ed404a0c2eafafc Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 19 Oct 2021 15:01:42 +0100 Subject: [PATCH] hypervisor: emulator: Print out all exception details Print out all the details from an emulator exception. As identified by the new beta clippy. Signed-off-by: Rob Bradford --- hypervisor/src/arch/emulator/mod.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hypervisor/src/arch/emulator/mod.rs b/hypervisor/src/arch/emulator/mod.rs index 2c02de89c..078f65525 100644 --- a/hypervisor/src/arch/emulator/mod.rs +++ b/hypervisor/src/arch/emulator/mod.rs @@ -18,7 +18,18 @@ pub struct Exception { impl Display for Exception { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "Exception {:?} at IP {:#x}", self.vector, self.ip) + write!( + f, + "Exception {:?} at IP {:#x}{}{}", + self.vector, + self.ip, + self.error + .map(|e| format!(": error {:x}", e)) + .unwrap_or_else(|| "".to_owned()), + self.payload + .map(|payload| format!(": payload {:x}", payload)) + .unwrap_or_else(|| "".to_owned()) + ) } }