From: Ian Jackson Date: Wed, 19 May 2021 19:16:22 +0000 (+0100) Subject: apitest: Explode: print the error chain too X-Git-Tag: otter-0.6.0~154 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=828d805aeeb94d55ee801330b3fb6ceca988f2b9;p=otter.git apitest: Explode: print the error chain too Signed-off-by: Ian Jackson --- 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 { } }