diff --git a/Cargo.toml b/Cargo.toml index b57c0e0..75cf80a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,6 +69,7 @@ wasm-bindgen-futures = "0.4.29" serde = { version = "1.0.136", features = ["derive"] } serde_derive = "1.0.123" futures = "0.3.12" +console_error_panic_hook = "0.1.7" # The `web-sys` crate allows you to interact with the various browser APIs, # like the DOM. diff --git a/src/lib.rs b/src/lib.rs index 7a63fde..103e9fe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,6 +25,8 @@ mod rate; use raw_window_handle::{DisplayHandle, HandleError, HasDisplayHandle, WindowHandle}; use std::{ffi::c_void, fmt, time::Duration}; +#[cfg(target_arch = "wasm32")] +use std::panic; #[cfg(target_arch = "wasm32")] use web_sys::HtmlElement; @@ -339,6 +341,8 @@ impl Window { height: usize, opts: WindowOptions, ) -> Result { + panic::set_hook(Box::new(console_error_panic_hook::hook)); + use web_sys::HtmlElement; if opts.transparency && !opts.borderless {