Quantcast
Channel: Pale Moon forum
Viewing all articles
Browse latest Browse all 2949

Browser Development • Re: Unexpected "uncaught exception" using async functions

$
0
0
Try this:

CODE:

<html><body><script>((Promise) => {  const originalThen = Promise.prototype.then;  const originalCatch = Promise.prototype.catch;  Promise.prototype.then = function (...args) {    console.log("Called .then on %o with arguments: %o", this, args);    return originalThen.apply(this, args);  };  Promise.prototype.catch = function (...args) {    console.error("Called .catch on %o with arguments: %o", this, args);    return originalCatch.apply(this, args);  };})(Promise);document.body.addEventListener('click', async function () {    async function usingPromiseReject() {        return Promise.reject('Using Promise.reject');    };    await usingPromiseReject().catch(err => console.log('Caught: ' + err));});</script>click</body></html>


Viewing all articles
Browse latest Browse all 2949

Trending Articles