add error logging for list download

This commit is contained in:
Viet Huynh
2023-09-29 06:51:12 +07:00
parent c2b0510cfc
commit e4f44e3e2b
+16 -10
View File
@@ -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) {