1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! The wasm panic hook: a Rust panic reaches the browser console instead of
//! the bare `RuntimeError: unreachable` wasm traps produce by default.
//!
//! [`set_once`](crate::panic_hook::set_once) is what every wasm entry point in the family calls first —
//! the kernel's `#[wasm_bindgen]` ABI, `brep_render::Engine::new`, the app's
//! `start` and its history worker. It replaces the `console_error_panic_hook`
//! crate, whose whole content this is; the kernel already links `wasm-bindgen`,
//! so owning it costs nothing and drops a dependency from three crates.
//!
//! On every non-wasm target it is a no-op, deliberately — and that is a change
//! from the crate it replaces. `console_error_panic_hook::set_once()` installed
//! a native hook too, one that printed the panic message alone; because the ABI
//! functions that call it also run in native tests and in `BREP_mcp`'s headless
//! host, the first ABI call there quietly cost every later panic its backtrace
//! and the `RUST_BACKTRACE` hint. Doing nothing leaves the standard hook in
//! place, which prints both.
/// Install the panic hook, at most once per module instance. Cheap enough to
/// call from every entry point, which is how it is used.