Created
September 19, 2018 12:33
-
-
Save cevek/a72bb77b75715bc7a9cf59789d4b84ac to your computer and use it in GitHub Desktop.
Devtools enhancement: Pause on exceptions inside promise.then or catch without checked caught in exceptions
This file contains hidden or 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
function create(fn, name) { | |
if (fn === undefined) return; | |
const callback = data => { | |
let ret; | |
new Promise(() => (ret = fn(data))); | |
return ret; | |
}; | |
callback.displayName = name; | |
return callback; | |
} | |
Promise.prototype.nativeThen = Promise.prototype.then; | |
Promise.prototype.nativeCatch = Promise.prototype.catch; | |
Promise.prototype.then = function (onFullFilled, onRejected) { | |
return this.nativeThen(create(onFullFilled, 'onFullFilled'), create(onRejected, 'onRejected')); | |
}; | |
Promise.prototype.catch = function (onRejected) { | |
return this.nativeCatch(create(onRejected, 'onRejected')); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment