diff --git a/events/unhandledRejection.js b/events/unhandledRejection.js new file mode 100644 index 0000000..8bd7b4b --- /dev/null +++ b/events/unhandledRejection.js @@ -0,0 +1,10 @@ +process.on('unhandledRejection', error => { + // Will print "unhandledRejection err is not defined" + console.log('unhandledRejection', error.message); +}); + +new Promise((_, reject) => reject(new Error('woops'))). + catch(error => { + // Will not execute + console.log('caught', err.message); + });