Hello I stumbled across an issue which I am not sure if i am just misunderstanding the ways Promises work or not. I am trying to catch unhandledPromiseRejection by wrapping all code inside a method in a parent promise so that it can catch the propagated errors.
function testFunction() {
new Promise((resolve,reject)=>{
const innerPromiseWithError = new Promise(resolve=>{
throw new Error("TESTTEST");
})
innerPromiseWithError.then();
//do smth else here;
}).catch(console.log);
Here I expect the catch to catch the rejected promise with the error caused by innerPromise but that is not being the case. Is there a flaw in my logic on how I am expecting this to be handled?