I am trying to catch an error that may be thrown within the catch of another promise. (sorry if that is confusing...)
async function throwingError () { throw new Error('this error needs to be caught'); // I don't know if I need to return, throw or something else. This function may or may not have an error }; async function mainFunction () { promiseFunction() .catch(error => { throwingError(); // I've tried throw throwingError() and return Promise.reject(throwingError()); }); }; mainFunction().catch(error => `caught: ${console.error}`); Right now, it doesn't catch the error.
From what I know, this doesn't work because the promises finish at different times, but I'm not sure.