From 7df979cd3ad518c57032bcf59ba27e4488d7b4d5 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Sun, 4 Aug 2024 09:45:27 +0300 Subject: [PATCH] wasm: Enable console.error() panic hook Makes debugging a little bit easier... --- Cargo.lock | 11 +++++++++++ bindings/wasm/Cargo.toml | 1 + bindings/wasm/lib.rs | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 35b1fe5c8..7877c782a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -392,6 +392,16 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + [[package]] name = "core-foundation-sys" version = "0.8.6" @@ -1041,6 +1051,7 @@ dependencies = [ name = "limbo-wasm" version = "0.0.3" dependencies = [ + "console_error_panic_hook", "limbo_core", "wasm-bindgen", ] diff --git a/bindings/wasm/Cargo.toml b/bindings/wasm/Cargo.toml index 56fe24c58..690b5da90 100644 --- a/bindings/wasm/Cargo.toml +++ b/bindings/wasm/Cargo.toml @@ -11,5 +11,6 @@ crate-type = ["cdylib"] path = "lib.rs" [dependencies] +console_error_panic_hook = "0.1.7" limbo_core = { path = "../../core", default-features = false } wasm-bindgen = "0.2" diff --git a/bindings/wasm/lib.rs b/bindings/wasm/lib.rs index 00d67a814..a4b5f2313 100644 --- a/bindings/wasm/lib.rs +++ b/bindings/wasm/lib.rs @@ -75,3 +75,8 @@ impl limbo_core::Wal for Wal { todo!() } } + +#[wasm_bindgen(start)] +pub fn init() { + console_error_panic_hook::set_once(); +} \ No newline at end of file