JS API for traps #89
Description
I proposed not to catch traps with wasm catch
instruction in #1 (comment). Even though it has not been decided yet, in this issue I'd like to discuss JS API changes in case we decide not to catch traps as I proposed.
To make this behavior consistent, traps should not be catchable both before and after they hit a JS frame. To this end, it might be convenient if we have JS API to create a WebAssembly trap, like
trap = new WebAssembly.Trap()
So that we can maintain its trap identity in both JS and wasm.
But the current JS API specifies if an exported function call traps, the JS frame that called the exported function should throw a WebAssembly.RuntimeError
.
So I'm wondering, should we preserve this behavior? If we should, we may have to make catch
not catch RuntimeError
exception. RuntimeError
contains various error conditions other than traps. I think most cases of RuntimeError
are unrecoverable errors, but would there be any case of non-trap RuntimeError
that should be caught by catch
instruction?
Or, would it be better to create WebAssembly.Trap
and change the JS API so that in case of a wasm trap, its embedding JS frame throws not RuntimeError
but Trap
instead, and catch
instruction catches all other JS exceptions except for Trap
?
cc @dschuff @mstarzinger @Ms2ger @lukewagner @rossberg
@backes (In case this has implementation issues)