4 个版本 (2 个破坏性版本)
0.3.1 | 2024年2月17日 |
---|---|
0.3.0 | 2024年2月17日 |
0.2.0 | 2024年2月17日 |
0.1.0 | 2024年2月16日 |
0.0.0 |
|
#7 in #human-friendly
每月下载量 35 次
15KB
305 行
panic
面向人类的恐慌消息。通过调用 std::panic::set_hook
来使错误对人类友好。这是原始 human-panic 包的分支。
自定义消息使用
use panic::setup_panic;
fn main() {
setup_panic! {
name: "Panic Wrapper",
short_name: "panic",
version: env!("CARGO_PKG_VERSION"),
repository: "https://github.com/exact-labs/panic",
messages: {
colors: (Color::Red, Color::White, Color::Green),
head: "Well, this is embarrassing. %(name) v%(version) had a problem and crashed. \nTo help us diagnose the problem you can send us a crash report\n",
body: "We have generated a report file at \"%(file_path)\". \nSubmit an issue or email with the subject of \"%(name) v%(version) crash report\" and include the report as an attachment at %(repository).\n",
footer: "We take privacy seriously, and do not perform any automated error collection. \nIn order to improve the software, we rely on people to submit reports. Thank you!"
}
};
println!("A normal log message");
panic!("OMG EVERYTHING IS ON FIRE!!!");
}
除非禁用了功能 only-release
,否则它只在发布模式下显示人性化的恐慌消息
依赖项
~5–15MB
~185K SLoC