So I tested this on the sandbox and this works:
globalThis.onunhandledrejection = event => {
console.log(event.promise);
console.log("TEST")// get the promise
console.log(event.reason); // get the rejection reason
};
const myPromise = new Promise((resolve, reject) => {
reject('Ouch');
});
myPromise.then(() => {
console.log('Hello world');
});
However if I put it inside my vscode extension code it does not handle rejections, neither does the "test" appear on the console. It doesn't break the extension too. Any ideas how to make it work?