Create unhandledRejection.js

This commit is contained in:
ItzEmerald authored and GitHub committed 2020-12-09 11:10:06 +00:00
1 parent 6f05545be6
commit 4ed2aff1b7
1 file changed
+10
+10
View File
@@ -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);
});