//show up to 3 error in alert let onerror = {}; onerror.max = 3; onerror.num = 0; window.onerror = function(msg, file, line) { if (onerror.num++ < onerror.max) { alert("ERROR: " + msg + "\n" + file + ":" + line); } }