How to catch all errors that are thrown asyncronously in a Promise

The problem I am facing is that somewhere in the code I am working with there is an error that I cannot catch. The simplest example of this would be the code below:

try {
    new Promise((res, rej) => rej(new Error('You cannot catch me. Haha')));
} catch (err) {
    conosle.error(err);
}

Result in the console

I don’t want to alter the code much. I want to be able to catch and ignore some errors like that. I am trying to replace Promise by wrapping it so that i can catch all errors of that sort.

I have tried asking ChatGPT and it doesn’t help much, so Googling will most probably not help also.