pub struct BreakpadHandler { /* private fields */ }Implementations§
Source§impl BreakpadHandler
impl BreakpadHandler
Sourcepub fn attach<P: AsRef<Path>>(
crash_dir: P,
install_opts: InstallOptions,
on_crash: Box<dyn CrashEvent>,
) -> Result<Self, Error>
pub fn attach<P: AsRef<Path>>( crash_dir: P, install_opts: InstallOptions, on_crash: Box<dyn CrashEvent>, ) -> Result<Self, Error>
Sets up a breakpad handler to catch exceptions/signals, writing out a minidump to the designated directory if a crash occurs. Only one handler can be attached at a time
Examples found in repository?
examples/handle_crash.rs (lines 4-19)
1fn main() {
2 let cur_dir = std::env::current_dir().unwrap();
3
4 let _handler = breakpad_handler::BreakpadHandler::attach(
5 cur_dir,
6 breakpad_handler::InstallOptions::BothHandlers,
7 Box::new(|minidump_path: std::path::PathBuf| {
8 println!("Minidump written to {}", minidump_path.display());
9
10 match std::fs::remove_file(&minidump_path) {
11 Ok(_) => {
12 println!("Removed {}", minidump_path.display());
13 }
14 Err(e) => {
15 println!("Failed to remove {}: {}", minidump_path.display(), e);
16 }
17 }
18 }),
19 )
20 .unwrap();
21
22 #[allow(unsafe_code)]
23 unsafe {
24 if std::env::args().any(|a| a == "--crash") {
25 let ptr: *mut u8 = std::ptr::null_mut();
26 *ptr = 42;
27 }
28 }
29}Trait Implementations§
Source§impl Drop for BreakpadHandler
impl Drop for BreakpadHandler
impl Send for BreakpadHandler
impl Sync for BreakpadHandler
Auto Trait Implementations§
impl Freeze for BreakpadHandler
impl RefUnwindSafe for BreakpadHandler
impl Unpin for BreakpadHandler
impl UnwindSafe for BreakpadHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more