fixing panic hook weirdness
This commit is contained in:
@@ -34,7 +34,8 @@ workspace = true
|
||||
optional = true
|
||||
|
||||
[features]
|
||||
default = ["sleep", "console_error_panic_hook"]
|
||||
default = ["sleep"]
|
||||
panic-hook = ["console_error_panic_hook"]
|
||||
sleep = ["web-sys", "web-sys/Window"]
|
||||
websocket = [
|
||||
"getrandom",
|
||||
|
||||
@@ -70,3 +70,15 @@ pub async fn sleep(ms: i32) -> Result<(), wasm_bindgen::JsValue> {
|
||||
js_fut.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
#[cfg(feature = "panic-hook")]
|
||||
pub fn set_panic_hook() {
|
||||
// When the `console_error_panic_hook` feature is enabled, we can call the
|
||||
// `set_panic_hook` function at least once during initialization, and then
|
||||
// we will get better error messages if our code ever panics.
|
||||
//
|
||||
// For more details see
|
||||
// https://github.com/rustwasm/console_error_panic_hook#readme
|
||||
console_error_panic_hook::set_once();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ zeroize = { workspace = true }
|
||||
|
||||
wasm-utils = { path = "../../common/wasm/utils" }
|
||||
|
||||
nym-bin-common = { path = "../../common/bin-common" }
|
||||
nym-credentials = { path = "../../common/credentials" }
|
||||
nym-credential-storage = { path = "../../common/credential-storage" }
|
||||
nym-bandwidth-controller = { path = "../../common/bandwidth-controller" }
|
||||
|
||||
@@ -17,6 +17,10 @@ use wasm_bindgen::prelude::*;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn main() {
|
||||
wasm_utils::console_log!("[rust main]: rust module loaded");
|
||||
wasm_utils::console_log!(
|
||||
"credential client version used: {:#?}",
|
||||
nym_bin_common::bin_info!()
|
||||
);
|
||||
wasm_utils::console_log!("[rust main]: setting panic hook");
|
||||
wasm_utils::set_panic_hook();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user