From ac77b691dff1126128527e0daa67017dd6a15e5c Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Thu, 6 Jul 2023 15:03:02 -0700 Subject: [PATCH] improve deadlock panic message --- web3_proxy/src/bin/web3_proxy_cli.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/web3_proxy/src/bin/web3_proxy_cli.rs b/web3_proxy/src/bin/web3_proxy_cli.rs index 8ddc1aa6..5ac7a353 100644 --- a/web3_proxy/src/bin/web3_proxy_cli.rs +++ b/web3_proxy/src/bin/web3_proxy_cli.rs @@ -97,16 +97,17 @@ fn main() -> anyhow::Result<()> { continue; } - println!("{} deadlocks detected", deadlocks.len()); + let mut msg = format!("{} deadlocks detected\n", deadlocks.len()); + for (i, threads) in deadlocks.iter().enumerate() { - println!("Deadlock #{}", i); + msg += &format!("Deadlock #{}", i); for t in threads { - println!("Thread Id {:#?}", t.thread_id()); - println!("{:#?}", t.backtrace()); + msg += &format!("Thread Id {:#?}\n", t.thread_id()); + msg += &format!("{:#?}\n", t.backtrace()); } } - panic!("deadlock detected!"); + panic!("{:#}", msg); }); }