-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Q: Accessing wasm exception contents externally #193
Comments
What The real C++ value thrown (what you can get from So in short, |
Great, as long as we can get the pointer, that should be sufficient. We can then call back into wasm with the pointer, and cast it to access the underlying object. But it's a little unclear to me what parameters need to be used for the tag - is this an implementation detail or a convention? I am assuming maybe
In general that discussion sounds awesome. Being able to map the C++ message into the JS error and vice versa would be quite useful. |
It looks this test gives examples of |
More accurately it should look like Alternatively, the tag can be created from JS as I'm not sure what emscripten does here. The former I think, but then the question is whether tags are (or can be) exported. |
Oh wow! This is exactly what I was looking for - this is what I was confused on. I didn't realize this was exported nicely or that it was using reference equality under the hood. Makes much more sense now, thanks :) |
So the integer returned is an offset into the wasm heap? Is that the right way to interpret it? |
Yes, it is a regular memory address. |
So there is a technique in the emscripten exception handling mechanism, where the c++ exception bubbles up from wasm to JS as a
Based on this info, I tried the same technique with wasm EH, but got a |
I played around with the current wasm exception handling implementation in latest chrome, using C++, emscripten and JS. I was able to throw an exception in C++ and catch it in JS, but it's unclear to me how to access the contents of the C++ exception, like the message string.
Example:
The log will print something like this, with the exception cause hardcoded to
wasm exception
:I see there is the
getArg
API on the exception object, where I can pass in aWebAssembly.Tag
, but I'm not exactly sure what this API is for.Is there any way in the current spec, or in any upcoming additions, to get access to the underlying C++ exception like this from JS, to be able to do some simple operations on it like log it?
I imagine some API as follows:
I've read through some of the related issues, like #183, #184, #189, #190 but didn't find an answer.
Thanks in advance.
The text was updated successfully, but these errors were encountered: