>> >> - throw JSError in JS > > My JSError do you mean something that is the result of calling `new Error` in > JS? I don't think that can or should interact at all with the C++ exception > handling mechanism. I see them as two orthogonal systems and trying to mix > them or conflate them is likely to lead to trouble.
Right, right, this was just the initial step to find a common ground from which to go up in our discussion. >> >> - throw C++ exception in JS > > I don't think it possible (or should be possible) to use a JS `throw` > statement to throw C++ exception.. C++ exceptions must be thrown by the > native `__cxa_throw` mechanism. In order words even if you have a handle to > C++ object you want to throw, I believe the only way to throw is to call back > into native code to perform a C++ throw. > > I could be wrong about this though.. @Heejin Ahn <mailto:ahee...@google.com> > can probably say more on this. For me it works. I have bound the RecognitionException (and many others, including std::exception) with embind and throw that in my JS code. It is catched in the catch() clause in JS and I can work with the exception, including sending it to C++ where it can be used to wrap it with `std::make_exception_ptr` and `std::rethrow_exception`. Great integration, I must say! The only little thing that is missing is the wrapping of the exception class as "normal class handle", as it is done for the other C++ classes in JS, to allow things like checking the type using `instanceof`. >> >> > I don't see why embind would need to be involved necessarily. Not all > programs use embind, and its possible to refer to C++ object via simple > pointers in JS. That's certainly true, but my confusion with all the things required to make this work with embind is already huge. Please don't add to that with more options :-D Thanks, Mike -- www.soft-gems.net -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/7F6534C2-FACD-423C-BBB1-DBB723212057%40googlemail.com.