1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
//! Panic handler installer functions for better debugging. //! //! Call only *one* of these, only once per thread. use std::panic; use maybe_unwind::capture_panic_info; /// Sets the thread local panic handler to record the unwind information pub fn replace_panic_hook() { panic::set_hook(Box::new(|info| { capture_panic_info(info); })); } /// Sets the thread local panic handler to record the unwind information /// and then execute the existing hook. pub fn chain_panic_hook() { let old = panic::take_hook(); panic::set_hook(Box::new(move |info| { capture_panic_info(info); old(info); })); }