1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-19 09:31:24 +00:00

ui: handle unresolved promise errors

This commit is contained in:
Steven Hugg 2019-08-22 13:14:35 -04:00
parent 84a6c6ff61
commit c131cc1169

View File

@ -274,6 +274,7 @@ function loadProject(preset_id:string) {
getSkeletonFile(preset_id).then((skel) => {
current_project.filedata[preset_id] = skel || "\n";
loadMainWindow(preset_id);
//alertInfo("No existing file found; loading default file");
});
}
});
@ -1662,7 +1663,7 @@ var qs = (function (a : string[]) {
function installErrorHandler() {
if (typeof window.onerror == "object") {
window.onerror = function (msgevent, url, line, col, error) {
var msgstr = msgevent['reason'] ? (msgevent['reason']+" (rejected)") : (msgevent+"");
var msgstr = msgevent+"";
console.log(msgevent, url, line, col, error);
// emulation threw EmuHalt
if (error instanceof EmuHalt || msgstr.indexOf("CPU STOP") >= 0) {
@ -1685,7 +1686,16 @@ function installErrorHandler() {
}
_pause();
};
window.onunhandledrejection = window.onerror;
}
if (typeof window.onunhandledrejection == "object") {
window.onunhandledrejection = function(event) {
var msg = (event && event.reason) + "";
if (ga) ga('send', 'exception', {
'exDescription': msg,
'exFatal': true
});
alertError(msg);
}
}
}