Hi Mike,

Can you share the link flags you are are using for your project?    We know
this works in at least some cases because we have a test for it:

See:

https://github.com/emscripten-core/emscripten/blob/main/test/core/test_exceptions_primary.cpp

and:

https://github.com/emscripten-core/emscripten/blob/main/test/core/test_exceptions_primary.out

I imagine there is some issue with the settings you are using.

Do you get any kind of backtrace when you see the `Aborted(native code
called abort())` message?  Normally I would expect to see a backtrace?
Does happens with you build with `-O0` vs `-O3`?  Any more information?

cheers,
sam

On Sat, Aug 19, 2023 at 5:05 AM 'Mike Lischke' via emscripten-discuss <
emscripten-discuss@googlegroups.com> wrote:

> 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
> <https://groups.google.com/d/msgid/emscripten-discuss/3E0EEA6F-D458-4771-8443-FD4E242808D4%40googlemail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAL_va29e-qnk%3DOQ%2Bg5crvZN8%3DO3AobCv2kwp-i3m-kN9JqBbMg%40mail.gmail.com.

Reply via email to