Skip to content

Commit 4b4d633

Browse files
capture Rust panic messages and output them to the console. (#5875)
* Capture Rust panic messages and output them to the console. * Update lockfile * Update bindings file --------- Co-authored-by: Lukas Taegert-Atkinson <[email protected]> Co-authored-by: Lukas Taegert-Atkinson <[email protected]>
1 parent a48b515 commit 4b4d633

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

rust/Cargo.lock

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/bindings_wasm/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ parse_ast = { path = "../parse_ast" }
99
xxhash = { path = "../xxhash" }
1010
js-sys = "0.3.77"
1111
getrandom = { version = "0.2.15", features = ["js"] }
12+
console_error_panic_hook = "0.1"
1213

1314
[lib]
1415
crate-type = ["cdylib", "rlib"]

rust/bindings_wasm/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@ use wasm_bindgen::prelude::*;
44

55
#[wasm_bindgen]
66
pub fn parse(code: String, allow_return_outside_function: bool, jsx: bool) -> Vec<u8> {
7+
console_error_panic_hook::set_once();
78
parse_ast(code, allow_return_outside_function, jsx)
89
}
910

1011
#[wasm_bindgen(js_name=xxhashBase64Url)]
1112
pub fn xxhash_base64_url(input: Uint8Array) -> String {
13+
console_error_panic_hook::set_once();
1214
xxhash::xxhash_base64_url(&input.to_vec())
1315
}
1416

1517
#[wasm_bindgen(js_name=xxhashBase36)]
1618
pub fn xxhash_base36(input: Uint8Array) -> String {
19+
console_error_panic_hook::set_once();
1720
xxhash::xxhash_base36(&input.to_vec())
1821
}
1922

2023
#[wasm_bindgen(js_name=xxhashBase16)]
2124
pub fn xxhash_base16(input: Uint8Array) -> String {
25+
console_error_panic_hook::set_once();
2226
xxhash::xxhash_base16(&input.to_vec())
2327
}

wasm/bindings_wasm.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ export interface InitOutput {
1313
readonly xxhashBase64Url: (a: number, b: number) => void;
1414
readonly xxhashBase36: (a: number, b: number) => void;
1515
readonly xxhashBase16: (a: number, b: number) => void;
16+
readonly __wbindgen_export_0: (a: number, b: number, c: number) => void;
17+
readonly __wbindgen_export_1: (a: number, b: number) => number;
18+
readonly __wbindgen_export_2: (a: number, b: number, c: number, d: number) => number;
1619
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
17-
readonly __wbindgen_export_0: (a: number, b: number) => number;
18-
readonly __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
19-
readonly __wbindgen_export_2: (a: number, b: number, c: number) => void;
2020
}
2121

2222
export type SyncInitInput = BufferSource | WebAssembly.Module;

wasm/bindings_wasm_bg.wasm.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const parse: (a: number, b: number, c: number, d: number, e: number) => v
55
export const xxhashBase64Url: (a: number, b: number) => void;
66
export const xxhashBase36: (a: number, b: number) => void;
77
export const xxhashBase16: (a: number, b: number) => void;
8+
export const __wbindgen_export_0: (a: number, b: number, c: number) => void;
9+
export const __wbindgen_export_1: (a: number, b: number) => number;
10+
export const __wbindgen_export_2: (a: number, b: number, c: number, d: number) => number;
811
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
9-
export const __wbindgen_export_0: (a: number, b: number) => number;
10-
export const __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
11-
export const __wbindgen_export_2: (a: number, b: number, c: number) => void;

0 commit comments

Comments
 (0)