Function nuts::panic_info [−][src]
pub fn panic_info() -> String
Read some information about currently processing activities. This should be called inside a panic hook.
This function is only available in debug mode as a runtime cost is associated with recording the necessary data at all times.
The correct flag for conditional compilation is #[cfg(debug_assertions)]
.
Example
fn add_nuts_hook() { #[cfg(debug_assertions)] let previous_hook = std::panic::take_hook(); std::panic::set_hook(Box::new(move |panic_info| { let nuts_info = nuts::panic_info(); #[cfg(features = "web-debug")] web_sys::console::error_1(&nuts_info.into()); #[cfg(not(features = "web-debug"))] eprintln!("{}", nuts_info); previous_hook(panic_info) })); }