Last active
May 13, 2016 14:19
-
-
Save ThomasFlorelli/056c0e3a1aee7e34d17a62489dc6fd1e to your computer and use it in GitHub Desktop.
Dangerous exception swallowing by promises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
try { | |
new Promise((resolve) => { | |
resolve('test'); | |
}).then(function () { | |
throw new Error('test'); | |
}); | |
} catch (e) { | |
console.log('Will not show'); | |
console.error(e); | |
} | |
process.on('unhandledExceptions', function (err) { | |
console.log('Unhandled exception (will not show either):'); | |
console.error(err); | |
}); | |
process.on('unhandledRejection', function (err) { | |
console.log('Unhandled rejection:'); | |
console.error(err); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment