-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
25 lines (23 loc) · 683 Bytes
/
Copy pathtest.js
File metadata and controls
25 lines (23 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const mockGetStore = async (fail) => {
if (fail) throw new Error("Store doesn't exist");
return "store";
};
const getAll = (fail) => {
return new Promise(async (resolve, reject) => {
const store = await mockGetStore(fail);
resolve(store);
}).catch(() => "caught fallback");
};
(async () => {
console.log("Starting Promise.all...");
try {
const result = await Promise.all([
getAll(false),
getAll(true) // This will throw in getStore
]);
console.log("Promise.all resolved:", result);
} catch (e) {
console.error("Promise.all caught error:", e);
}
console.log("Done.");
})();