Print fatal error message when the fatal error occurs (#1311)

This commit is contained in:
Hood Chatham 2021-03-11 13:34:23 -08:00 committed by GitHub
parent ab249a0a50
commit de7c342010
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -383,8 +383,10 @@ globalThis.languagePluginLoader = (async () => {
Module.noWasmDecoding =
false; // we preload wasm using the built in plugin now
Module.preloadedWasm = {};
let isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
let fatal_error_msg =
"Pyodide has suffered a fatal error, refresh the page. " +
"Please report this to the Pyodide maintainers.";
Module.fatal_error = function(e) {
for (let [key, value] of Object.entries(Module.public_api)) {
if (key.startsWith("_")) {
@ -397,12 +399,11 @@ globalThis.languagePluginLoader = (async () => {
continue;
}
if (typeof (value) === "function") {
Module.public_api[key] = function() {
throw Error("Pyodide has suffered a fatal error, refresh the page. " +
"Please report this to the Pyodide maintainers.");
}
Module.public_api[key] = function() { throw Error(fatal_error_msg); }
}
}
console.error(fatal_error_msg);
console.error("The cause of the fatal error was:\n", e);
throw e;
};