Last active
August 23, 2017 10:52
-
-
Save darobin/d8bda9acdd7facf931c7 to your computer and use it in GitHub Desktop.
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
// from the brilliant mind of sb | |
var _catch = Promise.prototype.catch; | |
Promise.prototype.catch = function () { | |
return _catch.call(this, function (err) { setTimeout(function () { throw(err); }, 0); }); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
okay. i get it then. so the setTimeout helps to unswallow subsequent errors in the chain, because when you setTimeout, it's async, so it gets popped back onto the call stack again after it gets queued, going through the event loop, and back onto the call stack with an intact stack trace.