fix(*): Add error handling for no pokedex entries

This commit is contained in:
Josh Creek
2024-07-12 14:25:22 +01:00
parent 2404499858
commit 2a33dc1781
+5 -1
View File
@@ -32,7 +32,6 @@
} }
async function fetchCatchRecords() { async function fetchCatchRecords() {
console.log('Fetching catch record data');
const response = await fetch('/api/catch-records'); const response = await fetch('/api/catch-records');
if (!response.ok) { if (!response.ok) {
throw new Error('Failed to fetch catch record data'); throw new Error('Failed to fetch catch record data');
@@ -53,6 +52,11 @@
personalNotes: '' personalNotes: ''
})); }));
if (newCatchRecords.length === 0) {
alert('No pokedex entries to create catch records for');
return;
}
const batchSize = 500; const batchSize = 500;
for (let i = 0; i < newCatchRecords.length; i += batchSize) { for (let i = 0; i < newCatchRecords.length; i += batchSize) {
const batch = newCatchRecords.slice(i, i + batchSize); const batch = newCatchRecords.slice(i, i + batchSize);