rust-cli / human-panic

Panic messages for humans.
https://docs.rs/human-panic
Apache License 2.0
1.66k stars 65 forks source link

Cause (Payload) Does Not Support Strings #58

Open frankwillis42 opened 5 years ago

frankwillis42 commented 5 years ago

https://github.com/rust-cli/human-panic/blob/200e427603841238a4a9ff97ca9e0c5d5b9be974/src/lib.rs#L220

The code attempts to downcast to &str but this will return None if the PanicInfo.payload() is a String. For example, consider the following panic:

panic!("this is a {}", "test");

The "Cause" will not be displayed in the "explanation" portion of the dump file as this panic has a payload of type String which is not &str. How do I get the Cause to show when I use a panic such as this? Or does this require a code change to support downcasting to other types such as String?