Skip to content

Commit

Permalink
Add console_error_panic_hook for panic messages in browser console on…
Browse files Browse the repository at this point in the history
… wasm
  • Loading branch information
augustkline committed Sep 5, 2024
1 parent 6111166 commit 2e2fdcf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -339,6 +341,8 @@ impl Window {
height: usize,
opts: WindowOptions,
) -> Result<Window> {
panic::set_hook(Box::new(console_error_panic_hook::hook));

use web_sys::HtmlElement;

if opts.transparency && !opts.borderless {
Expand Down

0 comments on commit 2e2fdcf

Please sign in to comment.