Emscripten’s Lost Exceptions and Regex Issues

Lost exception

An interesting feature of Emscripten is that when starting a game loop via emscripten_set_main_loop, you should remember that exception handling must be re-added via try catch directly in the loop method, since the runtime loses the try catch block from the outside.
The easiest way to display the error text is through the browser, using javascript alert:

            catch (const std::exception &exc)
            {
                const char *errorText = exc.what();
                cout << "Exception: " << errorText << "; Stop execution" << endl;

                EM_ASM_(
                {
                    var errorText = UTF8ToString($0);
                    alert(errorText);

                }, errorText);

                abort();

Too complex regexp

The std implementation of regex may throw an error_complexity exception if it finds the regular expression too complex. This happens in the current emscripten implementation, so I suggest you implement tests for parsing via regular expressions, or use third-party regex implementations.