From 0f3c6099b33bec9e0c89226085dffa172b701aa2 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 21 May 2019 10:22:13 +0200 Subject: [PATCH] MOBILE-3039 core: Fix allPromises error detection --- src/providers/utils/utils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/providers/utils/utils.ts b/src/providers/utils/utils.ts index 1569b505d..d3d09bf47 100644 --- a/src/providers/utils/utils.ts +++ b/src/providers/utils/utils.ts @@ -84,17 +84,19 @@ export class CoreUtilsProvider { return new Promise((resolve, reject): void => { const total = promises.length; let count = 0, + hasFailed = false, error; promises.forEach((promise) => { promise.catch((err) => { + hasFailed = true; error = err; }).finally(() => { count++; if (count === total) { // All promises have finished, reject/resolve. - if (error) { + if (hasFailed) { reject(error); } else { resolve();