display String panic msgs as well as &str ones

For #136. I'm also going to make this particular case no longer panic,
but there will surely be other affected panics.

Before:

```
E20210803 08:58:31.606 main moonfire_nvr] panic at '/Users/slamb/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.10/src/server/server.rs:68:17'
```

After:

```
E20210803 08:59:51.319 main moonfire_nvr] panic at '/Users/slamb/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.10/src/server/server.rs:68:17': error binding to 0.0.0.0:80: error creating server listener: Address already in use (os error 48)
```
This commit is contained in:
Scott Lamb 2021-08-03 09:00:37 -05:00
parent 84ce447fab
commit dcfe792032

View File

@ -87,6 +87,8 @@ fn panic_hook(p: &std::panic::PanicInfo) {
}
if let Some(s) = p.payload().downcast_ref::<&str>() {
write!(&mut msg, ": {}", s).unwrap();
} else if let Some(s) = p.payload().downcast_ref::<String>() {
write!(&mut msg, ": {}", s).unwrap();
}
let b = failure::Backtrace::new();
if b.is_empty() {