const getWASMPackMessage = (e) => e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString() let currentMessage = Symbol() const consoleError = console.error; console.error = function () { if (arguments[0] === "wasm-bindgen: imported JS function that was not marked as `catch` threw an error:" && arguments[1] === currentMessage) { return } else { consoleError.apply(this, arguments) } } /** @param {string} message */ export function hook(message) { const error = new WebAssembly.RuntimeError(message) currentMessage = getWASMPackMessage(error) queueMicrotask(() => currentMessage = Symbol()) throw error; }