Last active
January 5, 2016 07:40
-
-
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
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
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