You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
To handle an external exception, for example originating in JavaScript, one would naturally use a catch_all clause iiuc. The caught exception can (only) be rethrown unmodified as long as it does not escape the scope of the catch clause, implying some limitations. To give an example of what I mean, imagine the following pseudocode in Wasm with EH:
where ex cannot refer to the original exception since there is no such reference available when using a catch_all clause, so a compiler will likely utilize a substitute, say an ExternalException instance to represent the exception. When raising the exception again, this leads to an ambiguity within the catch clause if a language does not itself have an expression-less throw; instruction (JS for example considers this a syntax error) or likewise to indicate the intent to rethrow:
try {
maybeThrowExternalException();
} catch (Exceptionex) {
throwex; // rethrow the original or throw the substitute? what if ex is modified?
}
Furthermore, if the exception escapes the catch clause, the only available option becomes to throw the substitute, with the exception losing identity and being unable to refer to the original exception due the unavailable reference:
ExceptionescapedException;
try {
maybeThrowExternalException();
} catch (Exceptionex) {
escapedException = ex;
}
if (escapedException) throwex; // throw the substitute
Now I know that exnref has been removed for reasons, yet being able to reference an (external) exception in catch_all seems useful. Externally in JS this is not a problem because there is such a reference, a WebAssembly.Exception. Could there perhaps be a similar reference in Wasm when using/limited to a catch_all clause? Or are there clever tricks to emulate the desired behavior in a portable way?