Skip to main content

panic_message

Function panic_message 

Source
pub fn panic_message(panic: &Box<dyn Any + Send>) -> String
Expand description

What a caught panic actually said.

PUBLIC BECAUSE THE OTHER ELEVEN CRATES NEED IT. Each of them guards its own C entry points with catch_unwind and, having no way to reach this, reports the panic as "panic in <function>" – the name of the function that was running, which the caller already knew, in place of the message, which is the only part it did not. An index out of bounds, a slice out of range, an expect with a sentence in it: all of it was thrown away at the boundary.

The guards themselves are NOT shareable, and that is why this is what moved rather than ffi_guard. Each crate’s guard records the message into that crate’s own thread-local, which is what its own C callers read; a guard from here would record into this crate’s, and every panic message would land in a slot nobody reads.