Complete the code to listen for unhandled promise rejections.
process.on('unhandledRejection', [1] => { console.error('Unhandled rejection:', [1]); });
The event listener for 'unhandledRejection' receives the reason why the promise was rejected.
Complete the code to exit the process after logging an unhandled rejection.
process.on('unhandledRejection', reason => { console.error('Unhandled rejection:', reason); process.[1](1); });
Use process.exit(1) to stop the Node.js process with an error code after an unhandled rejection.
Fix the error in the unhandled rejection handler to correctly log the error stack.
process.on('unhandledRejection', (reason) => { console.error('Error stack:', [1]); });
The stack property of the error object shows the full stack trace for debugging.
Fill both blanks to create a handler that logs the error and then exits the process.
process.on('unhandledRejection', ([1]) => { console.error('Unhandled rejection:', [2]); process.exit(1); });
Using the same parameter name reason consistently helps clarity and correctness.
Fill all three blanks to create a robust unhandled rejection handler that logs the error stack, warns, and exits.
process.on('unhandledRejection', ([1]) => { console.error('Unhandled rejection stack:', [2]); console.warn('Warning: process will exit due to unhandled rejection'); process.[3](1); });
The handler uses reason as the parameter, logs reason.stack for details, and calls process.exit(1) to stop the app.