Unhandled Rejection Handler
NodeJS
Hard
3 views
Problem Description
Handle unhandledRejection and print a friendly message.
Output Format
Print one line.
Constraints
Add a process listener and trigger rejection.
Official Solution
process.on('unhandledRejection', (reason) => {
const msg = reason && reason.message ? reason.message : String(reason);
console.log('Unhandled: ' + msg);
});
Promise.reject(new Error('meetcode'));
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!