Panic messages for humans.
Panic messages for humans. Handles panics by calling
std::panic::set_hook
to make errors nice for humans.
When you're building a CLI, polish is super important. Even though Rust is pretty great at safety, it's not unheard of to access the wrong index in a vector or have an assert fail somewhere.
When an error eventually occurs, you probably will want to know about it. So instead of just providing an error message on the command line, we can create a call to action for people to submit a report.
This should empower people to engage in communication, lowering the chances people might get frustrated. And making it easier to figure out what might be causing bugs.
thread 'main' panicked at 'oops', examples/main.rs:2:3
note: Run with `RUST_BACKTRACE=1` for a backtrace.…The error dump file generated by human-panic contains the following fields.
…use human_panic::setup_panic;
fn main() {
setup_panic!();
println!("A normal log message");
panic!("OMG EVERYTHING IS ON FIRE!!!")
}It only displays a human-friendly panic message in release mode:
$ cargo run --release$ cargo add human-panicLicensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.
No open issues yet, or sync has not completed.