JSFiddle - React, Tailwind, and code Playground
by pipo02mix
JavaScript
window.onerror = function(message) {
log('error catched on global listener-> ' + message);
};
try {
setTimeout(function() {
try {
throw new Error('Error produced');
} catch (e) {
log('error catched inside the listener -> ' + e.message);
throw e;
}
}, 2000);
} catch (e) {
log('error catched outside the listener -> ' + e.message);
throw e;
}
function log(msg) {
var p = document.createElement('p');
p.innerHTML = msg;
document.body.appendChild(p);
}