handle-rejection
Version:
š Handle unhandled rejections
21 lines (15 loc) ⢠509 B
JavaScript
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);
});
});