{"id":2208,"date":"2019-09-24T23:07:46","date_gmt":"2019-09-24T20:07:46","guid":{"rendered":"http:\/\/demensdeum.com\/blog\/?p=2208"},"modified":"2024-12-16T22:32:34","modified_gmt":"2024-12-16T19:32:34","slug":"webassembly-lost-exceptions-and-regex-troubles","status":"publish","type":"post","link":"https:\/\/demensdeum.com\/blog\/2019\/09\/24\/webassembly-lost-exceptions-and-regex-troubles\/","title":{"rendered":"Emscripten&#8217;s Lost Exceptions and Regex Issues"},"content":{"rendered":"<h3>Lost exception<\/h3>\n<p>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.<br \/>The easiest way to display the error text is through the browser, using javascript alert:<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-unknown\" data-lang=\"unknown\"><code>            catch (const std::exception &exc)\n            {\n                const char *errorText = exc.what();\n                cout << \"Exception: \" << errorText << \"; Stop execution\" << endl;\n\n                EM_ASM_(\n                {\n                    var errorText = UTF8ToString($0);\n                    alert(errorText);\n\n                }, errorText);\n\n                abort();\n<\/code><\/pre>\n<\/div>\n<h3>Too complex regexp<\/h3>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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,<a class=\"more-link\" href=\"https:\/\/demensdeum.com\/blog\/2019\/09\/24\/webassembly-lost-exceptions-and-regex-troubles\/\">Continue reading <span class=\"screen-reader-text\">&#8220;Emscripten&#8217;s Lost Exceptions and Regex Issues&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[94,118,61],"tags":[119,121,120],"class_list":["post-2208","post","type-post","status-publish","format-standard","hentry","category-dev-diary","category-hints","category-techie","tag-emscripten","tag-hints","tag-webassembly","entry"],"translation":{"provider":"WPGlobus","version":"3.0.2","language":"en","enabled_languages":["en","ru","zh","de","fr","ja","pt"],"languages":{"en":{"title":true,"content":true,"excerpt":false},"ru":{"title":true,"content":true,"excerpt":false},"zh":{"title":true,"content":true,"excerpt":false},"de":{"title":true,"content":true,"excerpt":false},"fr":{"title":true,"content":true,"excerpt":false},"ja":{"title":true,"content":true,"excerpt":false},"pt":{"title":true,"content":true,"excerpt":false}}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/demensdeum.com\/blog\/wp-json\/wp\/v2\/posts\/2208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demensdeum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/demensdeum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/wp-json\/wp\/v2\/comments?post=2208"}],"version-history":[{"count":6,"href":"https:\/\/demensdeum.com\/blog\/wp-json\/wp\/v2\/posts\/2208\/revisions"}],"predecessor-version":[{"id":3942,"href":"https:\/\/demensdeum.com\/blog\/wp-json\/wp\/v2\/posts\/2208\/revisions\/3942"}],"wp:attachment":[{"href":"https:\/\/demensdeum.com\/blog\/wp-json\/wp\/v2\/media?parent=2208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/wp-json\/wp\/v2\/categories?post=2208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/wp-json\/wp\/v2\/tags?post=2208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}