diff --git a/lib/api.js b/lib/api.js index bd5cbfd..628ec9e 100644 --- a/lib/api.js +++ b/lib/api.js @@ -63,8 +63,12 @@ const createZeroTrustListsAtOnce = async (items) => { listNumber++; } - await Promise.all(requests); - console.log(`Created ${totalListNumber} lists`); + try { + await Promise.all(requests); + console.log(`Created ${totalListNumber} lists`); + } catch (err) { + console.error(`Error occurred while creating lists - ${err.toString()}`); + } }; /** diff --git a/lib/helpers.js b/lib/helpers.js index 69ea096..8fd511a 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -17,6 +17,10 @@ const request = async (url, options) => { ...options, }); + if (!response.ok) { + throw new Error(`HTTP error! Status: ${response.status}`); + } + return response.json(); };