web_panic_report 0.3.0

A panic hook which replaces an HTML element with a bug report form.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/// This is called from a button on the web example to allow the user to trigger a panic.
#[no_mangle]
pub extern "C" fn trigger_panic() {
    panic!("You triggered the panic!");
}

fn main() {
    // Set the panic hook at the beginning of your program
    web_panic_report::set_default_hook_with("test-container", |panic_info| {
        web_sys::window()
            .unwrap()
            .alert_with_message(&format!(
                "This is a custom callback!\n\n{}",
                panic_info.display
            ))
            .unwrap();
    });
}