Hi,

In my library I have to catch errors in JS and let C++ do something with them. 
A typical catch block in JS looks like this:

        catch (re) {
            if (re instanceof RecognitionException) {
                this.getErrorHandler().reportError(this, re);
                this.getErrorHandler().recover(this);
            } else {
                throw re;
            }
        }

The call to `recover` prints this message, however (-s ASSERTION used with -O3):

Aborted(native code called abort())

The native code is:

void BailErrorStrategy::recover(Parser *recognizer, std::exception_ptr e) {
  ParserRuleContext *context = recognizer->getContext();
  do {
    context->exception = e;
    if (context->parent == nullptr)
      break;
    context = static_cast<ParserRuleContext *>(context->parent);
  } while (true);

  try {
    std::rethrow_exception(e); // Throw the exception to be able to catch and 
rethrow nested.
  } catch (RecognitionException & /*inner*/) {
    std::throw_with_nested(ParseCancellationException());
  }
}

I traced the execution to the `std::rethrow_exception` line, which ends this 
call prematurely with the above error. To see if it is just a different 
exception I added a catch(...) clause, but that is never executed, so to me it 
looks as if `std::rethrow_exception` is something that cannot be used in 
WebAssembly. Is that assumption correct and what can I do to overcome that 
problem?

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/3E0EEA6F-D458-4771-8443-FD4E242808D4%40googlemail.com.

Reply via email to