| Crates.io | scoped-panic-hook |
| lib.rs | scoped-panic-hook |
| version | 0.1.2 |
| created_at | 2025-04-15 20:05:06.670281+00 |
| updated_at | 2025-04-25 17:48:19.818578+00 |
| description | Adds scoped, nestable, thread-local hooks for panics and some utilities for capturing and analyzing panics more conveniently |
| homepage | |
| repository | https://github.com/target-san/scoped-panic-hook |
| max_upload_size | |
| id | 1635161 |
| size | 41,235 |
This crate provides convenient API for obtaining panic info after unwinding
let result = catch_panic(|| {
panic!("Something bad happened!");
});
if let Err(panic) = result {
eprintln!("{}", panic.display_with_backtrace());
}
This will either produce normal result of closure or or conveniently gathered panic info, which includes panic location, message, raw payload and backtrace
hook - raw scoped hook APIspanic - all types and functions relevant to capturing panics, including some advanced featuresProject uses cargo-xtask pattern.
Run cargo xtask to see available commands
They're located in a separate unpublished subcrate. This is because most of them need to execute certain test case binary as a separate process and then analyze its output
Crate doesn't have separate feature nightly. Instead, it uses toolchain detection to automatically determine
whether to use nightly features or not.
While API remains the same, some internal behaviors are changed
update_hook instead of take_hook+set_hookstd::panic::get_backtrace_style
and is not hardcoded to shortThese tweaks will be hopefully moved to stable version when related features are stabilized