From e4f44e3e2b7b5de97b01c67e352aa5af6c56549c Mon Sep 17 00:00:00 2001 From: Viet Huynh Date: Fri, 29 Sep 2023 05:43:38 +0700 Subject: [PATCH] add error logging for list download --- download_lists.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/download_lists.js b/download_lists.js index fb0d952..9087e0f 100644 --- a/download_lists.js +++ b/download_lists.js @@ -23,16 +23,22 @@ const downloadLists = async (filename, urls) => { await unlink(filePath); } - await downloadFiles(filePath, urls); - console.log( - `Done. The ${filename} file contains merged data from the following list(s):` - ); - console.log( - urls.reduce( - (previous, current, index) => previous + `${index + 1}. ${current}\n`, - "" - ) - ); + try { + await downloadFiles(filePath, urls); + + console.log( + `Done. The ${filename} file contains merged data from the following list(s):` + ); + console.log( + urls.reduce( + (previous, current, index) => previous + `${index + 1}. ${current}\n`, + "" + ) + ); + } catch (err) { + console.error(`An error occurred while processing ${filename}:\n`, err); + console.error("URLs:\n", urls); + } }; switch (listType) {