I need to perform something like:
let promise1 = getPromise1();
let promise2 = getPromise2();
let promise3 = getPromise3();
// some more code
...
result1 = await promise1;
// work with result1 in specific way
result2 = await promise2;
// work with result2 in specific way
result3 = await promise3;
// work with result3 in specific way
Since I need to perform rather unique thingson each of the results, I do not want to work with Promise.all, as itd result in some nasty if-else structure.
My question is - where does try{}catch(){}
block come into place? Even if one of the promises errors, I do not want it to affect the other ones. They must finish execution regardless. Do I wrap single resultX
in try{}
or do I wrap let promiseX =...
. Or both?
Do you have better design pattern in mind?
Thanks!