JSFiddle - React, Tailwind, and code Playground
by krofdrakula
JavaScript
const h = (name, attrs, text) => {
const el = document.createElement(name);
for (const [name,value] of Object.entries(attrs))
el[name] = value;
el.textContent = text;
return el;
}
const log = (msg) => {
document.body.appendChild(h('p', { style: 'color: green' }, msg));
}
const error = (err) => {
document.body.appendChild(h('p', { style: 'color: red' }, err.reason ?? err.toString()));
}
Promise.reject('Whatever').catch(() => {})
window.addEventListener('unhandledrejection', err => {error(`Unhandled rejection!`); error(err)});
window.addEventListener('handledrejection', msg => log(msg));