rust-cli / human-panic

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

Missing doc on exact usage of this crate #76

Closed matthiasbeyer closed 1 year ago

matthiasbeyer commented 3 years ago

Choose one: is this a 🐛 bug report

Missing docs are a bug, right? :laughing:

So what I am missing is just a short explanation where to call the setup_panic!() macro, actually: Inside main? Outside of any function? Just a bit of confusion on my end because the docs do not show where to put the call.

Thanks for this nice crate!

onkoe commented 1 year ago

In general, it depends on how early you're willing to print a human-readable panic. If you set it later into your program's logic, then you could possibly have a panic which doesn't use this library's panic hook - meaning the message will just be "panicking because of thing hahah!"

For that reason, most people will want to put it in their program's entrypoint. For almost all Rust binaries, that'll be somewhere at the top of main(), or even as the first line of main. Again, the earlier you set the hook, the more clear-cut (and reportable) panics will be to your users.

I hope that helps! If you have any other questions, please let me know! :)