Skip to content

Instantly share code, notes, and snippets.

@ThomasFlorelli
Last active May 13, 2016 14:19
Show Gist options
  • Save ThomasFlorelli/056c0e3a1aee7e34d17a62489dc6fd1e to your computer and use it in GitHub Desktop.
Save ThomasFlorelli/056c0e3a1aee7e34d17a62489dc6fd1e to your computer and use it in GitHub Desktop.
Dangerous exception swallowing by promises
'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