mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
ignorable exceptions
This commit is contained in:
parent
7f8777389c
commit
0eb3a5d387
|
@ -926,8 +926,11 @@ function up2k_init(subtle) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clearTimeout(tto);
|
clearTimeout(tto);
|
||||||
|
if (crashed)
|
||||||
|
return defer();
|
||||||
|
|
||||||
running = true;
|
running = true;
|
||||||
while (window['vis_exh']) {
|
while (true) {
|
||||||
var now = Date.now(),
|
var now = Date.now(),
|
||||||
is_busy = 0 !=
|
is_busy = 0 !=
|
||||||
st.todo.head.length +
|
st.todo.head.length +
|
||||||
|
@ -1009,7 +1012,7 @@ function up2k_init(subtle) {
|
||||||
mou_ikkai = true;
|
mou_ikkai = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mou_ikkai)
|
if (!mou_ikkai || crashed)
|
||||||
return defer();
|
return defer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1519,7 +1522,7 @@ function up2k_init(subtle) {
|
||||||
try { orz(xhr); } catch (ex) { vis_exh(ex + '', '', '', '', ex); }
|
try { orz(xhr); } catch (ex) { vis_exh(ex + '', '', '', '', ex); }
|
||||||
};
|
};
|
||||||
xhr.onerror = function (xev) {
|
xhr.onerror = function (xev) {
|
||||||
if (!window['vis_exh'])
|
if (crashed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
console.log('chunkpit onerror, retrying', t);
|
console.log('chunkpit onerror, retrying', t);
|
||||||
|
|
|
@ -11,6 +11,12 @@ var is_touch = 'ontouchstart' in window,
|
||||||
ANDROID = /android/i.test(navigator.userAgent);
|
ANDROID = /android/i.test(navigator.userAgent);
|
||||||
|
|
||||||
|
|
||||||
|
var ebi = document.getElementById.bind(document),
|
||||||
|
QS = document.querySelector.bind(document),
|
||||||
|
QSA = document.querySelectorAll.bind(document),
|
||||||
|
mknod = document.createElement.bind(document);
|
||||||
|
|
||||||
|
|
||||||
// error handler for mobile devices
|
// error handler for mobile devices
|
||||||
function esc(txt) {
|
function esc(txt) {
|
||||||
return txt.replace(/[&"<>]/g, function (c) {
|
return txt.replace(/[&"<>]/g, function (c) {
|
||||||
|
@ -22,16 +28,18 @@ function esc(txt) {
|
||||||
}[c];
|
}[c];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
var crashed = false, ignexd = {};
|
||||||
function vis_exh(msg, url, lineNo, columnNo, error) {
|
function vis_exh(msg, url, lineNo, columnNo, error) {
|
||||||
if ((msg + '').indexOf('ResizeObserver') !== -1)
|
if ((msg + '').indexOf('ResizeObserver') !== -1)
|
||||||
return; // chrome issue 809574 (benign, from <video>)
|
return; // chrome issue 809574 (benign, from <video>)
|
||||||
|
|
||||||
if (!window.onerror)
|
var ekey = url + '\n' + lineNo + '\n' + msg;
|
||||||
|
if (ignexd[ekey] || crashed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
crashed = true;
|
||||||
window.onerror = undefined;
|
window.onerror = undefined;
|
||||||
window['vis_exh'] = null;
|
var html = ['<h1>you hit a bug!</h1><p style="font-size:1.3em;margin:0">try to <a href="#" onclick="localStorage.clear();location.reload();" style="text-decoration:underline;color:#fc0">reset copyparty settings</a> if you are stuck here, or <a href="#" onclick="ignex();">ignore this</a> / <a href="#" onclick="ignex(true);">ignore all</a></p><p>please send me a screenshot arigathanks gozaimuch: <code>ed/irc.rizon.net</code> or <code>ed#2644</code><br /> (and if you can, press F12 and include the "Console" tab in the screenshot too)</p><p>',
|
||||||
var html = ['<h1>you hit a bug!</h1><p style="font-size:1.3em;margin:0">try to <a href="#" onclick="localStorage.clear();location.reload();" style="text-decoration:underline;color:#fc0">reset copyparty settings</a> if you are stuck here</p><p>please send me a screenshot arigathanks gozaimuch: <code>ed/irc.rizon.net</code> or <code>ed#2644</code><br /> (and if you can, press F12 and include the "Console" tab in the screenshot too)</p><p>',
|
|
||||||
esc(url + ' @' + lineNo + ':' + columnNo), '<br />' + esc(String(msg)) + '</p>'];
|
esc(url + ' @' + lineNo + ':' + columnNo), '<br />' + esc(String(msg)) + '</p>'];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -42,23 +50,38 @@ function vis_exh(msg, url, lineNo, columnNo, error) {
|
||||||
html.push('<h3>' + find[a] + '</h3>' +
|
html.push('<h3>' + find[a] + '</h3>' +
|
||||||
esc(String(error[find[a]])).replace(/\n/g, '<br />\n'));
|
esc(String(error[find[a]])).replace(/\n/g, '<br />\n'));
|
||||||
}
|
}
|
||||||
|
ignexd[ekey] = true;
|
||||||
html.push('<h3>localStore</h3>' + esc(JSON.stringify(localStorage)));
|
html.push('<h3>localStore</h3>' + esc(JSON.stringify(localStorage)));
|
||||||
}
|
}
|
||||||
catch (e) { }
|
catch (e) { }
|
||||||
document.body.innerHTML = html.join('\n');
|
|
||||||
|
|
||||||
var s = mknod('style');
|
try {
|
||||||
s.innerHTML = 'body{background:#333;color:#ddd;font-family:sans-serif;font-size:0.8em;padding:0 1em 1em 1em} h1{margin:.5em 1em 0 0;padding:0} h3{border-top:1px solid #999;margin:1em 0 0 0} code{color:#bf7;background:#222;padding:.1em;margin:.2em;font-size:1.1em;font-family:monospace,monospace} *{line-height:1.5em}';
|
var exbox = ebi('exbox');
|
||||||
document.head.appendChild(s);
|
if (!exbox) {
|
||||||
|
exbox = mknod('div');
|
||||||
|
exbox.setAttribute('id', 'exbox');
|
||||||
|
document.body.appendChild(exbox);
|
||||||
|
|
||||||
|
var s = mknod('style');
|
||||||
|
s.innerHTML = '#exbox{background:#333;color:#ddd;font-family:sans-serif;font-size:0.8em;padding:0 1em 1em 1em;z-index:80386;position:fixed;top:0;left:0;right:0;bottom:0;width:100%;height:100%} #exbox h1{margin:.5em 1em 0 0;padding:0} #exbox h3{border-top:1px solid #999;margin:1em 0 0 0} #exbox code{color:#bf7;background:#222;padding:.1em;margin:.2em;font-size:1.1em;font-family:monospace,monospace} #exbox *{line-height:1.5em}';
|
||||||
|
document.head.appendChild(s);
|
||||||
|
}
|
||||||
|
exbox.innerHTML = html.join('\n');
|
||||||
|
exbox.style.display = 'block';
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
document.body.innerHTML = html.join('\n');
|
||||||
|
}
|
||||||
throw 'fatal_err';
|
throw 'fatal_err';
|
||||||
}
|
}
|
||||||
|
function ignex(all) {
|
||||||
|
var o = ebi('exbox');
|
||||||
var ebi = document.getElementById.bind(document),
|
o.style.display = 'none';
|
||||||
QS = document.querySelector.bind(document),
|
o.innerHTML = '';
|
||||||
QSA = document.querySelectorAll.bind(document),
|
crashed = false;
|
||||||
mknod = document.createElement.bind(document);
|
if (!all)
|
||||||
|
window.onerror = vis_exh;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function ctrl(e) {
|
function ctrl(e) {
|
||||||
|
|
Loading…
Reference in a new issue