mirror of
https://github.com/Nezumi-2711/cloudflare-gateway-pihole-scripts.git
synced 2026-09-22 05:31:50 +00:00
handle API error
This commit is contained in:
+6
-2
@@ -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()}`);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,10 @@ const request = async (url, options) => {
|
||||
...options,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user