Skip to content

Commit

Permalink
Module['onRuntimeInitializeFailed']
Browse files Browse the repository at this point in the history
  • Loading branch information
buu700 committed Jul 3, 2017
1 parent f6d1438 commit 4cf6fe1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -2509,7 +2509,7 @@ function integrateWasmJS(Module) {
} else if (curr === 'interpret-asm2wasm' || curr === 'interpret-s-expr' || curr === 'interpret-binary') {
if (exports = doWasmPolyfill(global, env, providedBuffer, curr)) break;
} else {
throw 'bad method: ' + curr;
Module['quit'](1, 'bad method: ' + curr);
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ if (!ENVIRONMENT_IS_PTHREAD) PthreadWorkerInit = {};
var currentScriptUrl = ENVIRONMENT_IS_WORKER ? undefined : document.currentScript.src;
#endif

function runtimeInitializeFailed(status, toThrow) {
if (Module['onRuntimeInitializeFailed']) {
setTimeout(function () { Module['onRuntimeInitializeFailed'](status, toThrow); }, 0);
}
}

if (ENVIRONMENT_IS_NODE) {
// Expose functionality in the same simple way that the shells work
// Note that we pollute the global namespace here, otherwise we break in node
Expand Down Expand Up @@ -153,6 +159,7 @@ else if (ENVIRONMENT_IS_SHELL) {

if (typeof quit === 'function') {
Module['quit'] = function(status, toThrow) {
runtimeInitializeFailed(status, toThrow);
quit(status);
}
}
Expand Down Expand Up @@ -250,6 +257,7 @@ if (!Module['thisProgram']) {
}
if (!Module['quit']) {
Module['quit'] = function(status, toThrow) {
runtimeInitializeFailed(status, toThrow);
throw toThrow;
}
}
Expand Down

0 comments on commit 4cf6fe1

Please sign in to comment.