rescue some exceptions from the promise maelstroms

This commit is contained in:
ed 2022-07-15 23:42:37 +02:00
parent 780fc4639a
commit 8b6bd0e6ac

View file

@ -1625,7 +1625,7 @@ function up2k_init(subtle) {
hash_calc(nch, e.target.result); hash_calc(nch, e.target.result);
} }
reader.onload = function (e) { reader.onload = function (e) {
try { orz(e); } catch (ex) { vis_exh(ex + '', '', '', '', ex); } try { orz(e); } catch (ex) { vis_exh(ex + '', 'up2k.js', '', '', ex); }
}; };
reader.onerror = function () { reader.onerror = function () {
var err = reader.error + ''; var err = reader.error + '';
@ -1658,7 +1658,7 @@ function up2k_init(subtle) {
var hash_calc = function (nch, buf) { var hash_calc = function (nch, buf) {
while (segm_next()); while (segm_next());
var hash_done = function (hashbuf) { var orz = function (hashbuf) {
var hslice = new Uint8Array(hashbuf).subarray(0, 33), var hslice = new Uint8Array(hashbuf).subarray(0, 33),
b64str = buf2b64(hslice); b64str = buf2b64(hslice);
@ -1684,6 +1684,10 @@ function up2k_init(subtle) {
tasker(); tasker();
}; };
var hash_done = function (hashbuf) {
try { orz(hashbuf); } catch (ex) { vis_exh(ex + '', 'up2k.js', '', '', ex); }
};
if (subtle) if (subtle)
subtle.digest('SHA-512', buf).then(hash_done); subtle.digest('SHA-512', buf).then(hash_done);
else setTimeout(function () { else setTimeout(function () {
@ -1751,7 +1755,7 @@ function up2k_init(subtle) {
tasker(); tasker();
}; };
xhr.onload = function (e) { xhr.onload = function (e) {
try { orz(e); } catch (ex) { vis_exh(ex + '', '', '', '', ex); } try { orz(e); } catch (ex) { vis_exh(ex + '', 'up2k.js', '', '', ex); }
}; };
xhr.open('HEAD', t.purl + uricom_enc(t.name) + '?raw', true); xhr.open('HEAD', t.purl + uricom_enc(t.name) + '?raw', true);
@ -1965,7 +1969,7 @@ function up2k_init(subtle) {
} }
} }
xhr.onload = function (e) { xhr.onload = function (e) {
try { orz(e); } catch (ex) { vis_exh(ex + '', '', '', '', ex); } try { orz(e); } catch (ex) { vis_exh(ex + '', 'up2k.js', '', '', ex); }
}; };
var req = { var req = {
@ -2060,7 +2064,7 @@ function up2k_init(subtle) {
pvis.prog(t, npart, xev.loaded); pvis.prog(t, npart, xev.loaded);
}; };
xhr.onload = function (xev) { xhr.onload = function (xev) {
try { orz(xhr); } catch (ex) { vis_exh(ex + '', '', '', '', ex); } try { orz(xhr); } catch (ex) { vis_exh(ex + '', 'up2k.js', '', '', ex); }
}; };
xhr.onerror = function (xev) { xhr.onerror = function (xev) {
if (crashed) if (crashed)