I am also trying to get the PanicInfo from a panic.
As you can see, oddly, downcasting a panic to a PanicInfo is not possible (why?) and downcasting to a &str returns the payload but not the location.
use std::panic;
fn main() {
let p = panic::catch_unwind(|| panic!("A wild panic appeared!"));
let err = p.unwrap_err();
println!("{:#?}", err.downcast_ref::<panic::PanicInfo>()); // None
println!("{:#?}", err.downcast_ref::<&str>()); // Some("A wild panic appeared!")
}
There Is a away to smuggle a backtrace into the panic, but if my program is multithreaded, i'm afraid this approach might become a little clusmy to program?
Does anyone know otherwise how to extract the PanicInfo from a panic?