How to display `Box<Any>` taken from `catch_panic`?

My lib is supposed to run arbitrary rust code that might panic, but I can't just abort the program in case it happened. I'd like to catch such foreign panics and display them myself.

To catch a panic I can use catch_panic (no wonder) but how do I extract the message? If I get it right, it's not guaranteed to be &str or String.

The standard library checks for the cases of it being &str and String: https://github.com/rust-lang/rust/blob/master/src/libstd/panicking.rs#L171-L177

2 Likes

Yeah, I guess this is the best I can get :sleepy:. Thank you!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.