Skip to content

Instantly share code, notes, and snippets.

@briancavalier
Last active January 5, 2016 07:40
Show Gist options
  • Save briancavalier/eb9645705047a650b337 to your computer and use it in GitHub Desktop.
Save briancavalier/eb9645705047a650b337 to your computer and use it in GitHub Desktop.
Helper for simple support for source maps in when.js unhandled rejection reporting
var when = require('when');
unhandledRejectionsWithSourceMaps(when.Promise);
function unhandledRejectionsWithSourceMaps(Promise) {
Promise.onPotentiallyUnhandledRejection = function(r) {
setTimeout(function() {
if(!r.handled) {
throw r.value;
}
}, 0);
};
Promise.onPotentiallyUnhandledRejectionHandled = function(r) {
setTimeout(function() {
console.log('Handled previous rejection', String(r.value));
}, 0);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment