Function errloc_macros::msg [] [src]

pub fn msg<'a>(e: &'a Box<Any + Send + 'static>) -> &'a str

This function extracts message from the panic payload, that is obtained from std::panic::catch_unwind

This function extracts &str or std::string::String message that was provided as a payload to panic! macro. Result is returned as a &str and has the same lifetime as an input payload.

Usage example:

std::panic::catch_unwind(|| {
    panic!("Forty two");
}).unwrap_or_else(|e| {
    assert_eq!("Forty two", errloc_macros::msg(&e));
});