From 110be7f94c6cfb7c4bed2625a3793e8fea4366c0 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Fri, 14 Sep 2018 06:31:13 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Improve=20error=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssn/getPatch.ts | 6 +++++- src/ssn/patcher-installer/taskManager.ts | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ssn/getPatch.ts b/src/ssn/getPatch.ts index 08c2496..0239d27 100644 --- a/src/ssn/getPatch.ts +++ b/src/ssn/getPatch.ts @@ -175,7 +175,11 @@ export default async function getPatch({ product, from, to, sourceDirectory, tar } //run tasks - await taskManager(tasks, 5); + try { + await taskManager(tasks, 5); + } catch (error) { + throw new Error(error); + } //TODO: add option to delete downloaded files once patching is complete } diff --git a/src/ssn/patcher-installer/taskManager.ts b/src/ssn/patcher-installer/taskManager.ts index 3e51068..ebd1008 100644 --- a/src/ssn/patcher-installer/taskManager.ts +++ b/src/ssn/patcher-installer/taskManager.ts @@ -12,9 +12,8 @@ export default function taskManager(tasks: Array<() => Promise>, maxConcur } else { //If there is at least one task left, complete it const curTask = remainingTasks.pop() as () => Promise; - const curPromise = curTask(); currentlyRunningTasks += 1; - curPromise.then(() => { + curTask().then(() => { currentlyRunningTasks -= 1; return startNewTask(); }).catch((error) => {