From 828d805aeeb94d55ee801330b3fb6ceca988f2b9 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 19 May 2021 20:16:22 +0100 Subject: [PATCH] apitest: Explode: print the error chain too Signed-off-by: Ian Jackson --- apitest/apitest.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apitest/apitest.rs b/apitest/apitest.rs index b38494d1..04aeaef1 100644 --- a/apitest/apitest.rs +++ b/apitest/apitest.rs @@ -92,8 +92,17 @@ impl AsRef for Opts { fn as_ref(&self) -> &Opts { self } } #[derive(Debug)] pub enum Explode { } -impl From for Explode { - fn from(e: E) -> Explode { panic!("exploding on error: {}", e) } +impl<'e, E:Into>> From for Explode { + fn from(e: E) -> Explode { + let mut m = "exploding on error".to_string(); + let e: Box = e.into(); + let mut e: Option<&dyn Error> = Some(&*e); + while let Some(te) = e { + m += &format!(": {}", &te); + e = te.source(); + } + panic!("{}", m); + } } impl From for anyhow::Error { fn from(e: Explode) -> AE { match e { } } -- 2.30.2