UNPKG

handle-rejection

Version:

šŸ’€ Handle unhandled rejections

21 lines (15 loc) • 509 B
const errors = []; module.exports = error => errors.push(error); process.on('beforeExit', () => { if (!errors.length) { return; } const {log, error} = console; log('╭─────────────────────────────╮'); log('│ Unhandled Rejection Summary │'); log('╰─────────────────────────────╯'); errors.forEach((e, i) => { log(`\nā—ļø Rejection ${i + 1}:`); error(e); }); });