Macro panic_context::panic_context [] [src]

macro_rules! panic_context {
    ($($arg:tt)+) => { ... };
}

Remembers message to show it on panic inside current scope.

All arguments are passed to format! in order to compose message. Context is forgotten at the end of current scope.

Uses

Message is always remembered in both debug and release builds. See debug_panic_context! for context which is not enabled in release builds by default.

Examples

#[macro_use] extern crate panic_context;
for item in items {
    panic_context!("item: {}", item);
    process_item(item);
}

If panic occurs during item processing, then panic context will be printed:

Panic context:
item: cucumber
thread 'main' panicked at '...', src/libcore/str/mod.rs:2162
note: Run with `RUST_BACKTRACE=1` for a backtrace.