1 个稳定版本
1.0.4 | 2022年11月15日 |
---|---|
1.0.3 |
|
1.0.2 |
|
1.0.1 |
|
1.0.0 |
|
#17 in #panic-handler
6KB
pretty-panic
一个用于使您的丑陋的恐慌信息更友好的 Rust 库。
这是什么?
pretty-panic
是一个围绕 std::panic::set_hook
的库,允许您设置自己的恐慌处理函数。它提供了一个默认处理函数,只需打印更友好的恐慌信息。
如何使用?
代码
use pretty_panic::pretty_panic;
fn main() {
pretty_panic!(/* you would put your handler function here */);
panic!("explicit call to panic!()");
}
输出
Uh oh!
The program experienced a fatal error, and has panicked. Recommend you contact one
of the authors for assistance. See below for some additional information:
(If you are going to submit a bug report, include the entirety of this message!)
pretty-panic v0.1.0 () - panic start
panic from thread [main]:
panicked at 'explicit call to panic!()', examples/simple.rs:6:5
Submit bug report to the authors:
pretty-panic v0.1.0 () - panic end
安装
将以下内容添加到您的 Cargo.toml
文件的 [dependencies]
部分
[dependencies]
pretty-panic = "1.0"