handle unhelpful 'Script error.' message

This commit is contained in:
ansuz 2020-11-04 10:28:52 +05:30
parent 553f29b431
commit 59eaf8187c
2 changed files with 14 additions and 4 deletions

View File

@ -312,25 +312,35 @@ button.primary:hover{
return bar;
};
var hasErrored = false;
var updateLoadingProgress = function (data) {
if (!built) { return; }
if (!built || !data) { return; }
var c = types.indexOf(data.type);
if (c < current) { return console.error(data); }
try {
document.querySelector('.cp-loading-spinner-container').style.display = 'none';
document.querySelector('.cp-loading-progress-list').innerHTML = makeList(data);
document.querySelector('.cp-loading-progress-container').innerHTML = makeBar(data);
} catch (e) { console.error(e); }
} catch (e) {
if (!hasErrored) { console.error(e); }
}
};
window.CryptPad_updateLoadingProgress = updateLoadingProgress;
window.CryptPad_loadingError = function (err) {
if (!built) { return; }
hasErrored = true;
var err2;
if (err === 'Script error.') {
err2 = Messages.error_unhelpfulScriptError;
}
try {
var node = document.querySelector('.cp-loading-progress');
if (node.parentNode) { node.parentNode.removeChild(node); }
document.querySelector('.cp-loading-spinner-container').setAttribute('style', 'display:none;');
document.querySelector('#cp-loading-message').setAttribute('style', 'display:block;');
document.querySelector('#cp-loading-message').innerText = err;
document.querySelector('#cp-loading-message').innerText = err2 || err;
} catch (e) { console.error(e); }
};
return function () {

View File

@ -43,7 +43,7 @@ define([
return void console.log();
}
if (window.CryptPad_loadingError) {
window.CryptPad_loadingError(e);
return void window.CryptPad_loadingError(e);
}
throw e;
};