Skip to content

Commit f75c154

Browse files
committed
fix: improve error handling messages and add critical error state for image generation
1 parent 9acb668 commit f75c154

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

custom/visionAction.vue

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
/>
4444
<div class="flex w-full items-end justify-end gap-4">
4545
<div class="h-full text-red-600 font-semibold flex items-center justify-center mb-2">
46-
<p v-if="isError === true">{{ "Network error, please try again" }}</p>
46+
<p v-if="isError === true">{{ errorMessage }}</p>
4747
</div>
4848
<button type="button" class="py-2.5 px-5 ms-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
4949
@click="closeDialog"
@@ -53,7 +53,7 @@
5353
<Button
5454
class="w-64"
5555
@click="saveData"
56-
:disabled="isLoading || checkedCount < 1"
56+
:disabled="isLoading || checkedCount < 1 || isCriticalError"
5757
:loader="isLoading"
5858
>
5959
{{ checkedCount > 1 ? 'Save fields' : 'Save field' }}
@@ -106,6 +106,7 @@ const primaryKey = props.meta.primaryKey;
106106
const openGenerationCarousel = ref([]);
107107
const isLoading = ref(false);
108108
const isError = ref(false);
109+
const isCriticalError = ref(false);
109110
const errorMessage = ref('');
110111
const checkedCount = ref(0);
111112
@@ -143,7 +144,7 @@ const openDialog = async () => {
143144
}
144145
145146
watch(selected, (val) => {
146-
//console.log('Selected changed:', val);
147+
console.log('Selected changed:', val);
147148
checkedCount.value = val.filter(item => item.isChecked === true).length;
148149
}, { deep: true });
149150
@@ -254,7 +255,7 @@ async function getRecords() {
254255
} catch (error) {
255256
console.error('Failed to get records:', error);
256257
isError.value = true;
257-
errorMessage.value = `Failed to get records ${error}. Please, try to re-run the action.`;
258+
errorMessage.value = `Failed to fetch records. Please, try to re-run the action.`;
258259
// Handle error appropriately
259260
}
260261
}
@@ -272,7 +273,7 @@ async function getImages() {
272273
} catch (error) {
273274
console.error('Failed to get images:', error);
274275
isError.value = true;
275-
errorMessage.value = `Failed to get images ${error}. Please, try to re-run the action.`;
276+
errorMessage.value = `Failed to fetch images. Please, try to re-run the action.`;
276277
// Handle error appropriately
277278
}
278279
}
@@ -353,9 +354,9 @@ async function analyzeFields() {
353354
}
354355
})
355356
} catch (error) {
356-
console.error('Failed to get records:', error);
357+
console.error('Failed to analyze image(s):', error);
357358
isError.value = true;
358-
errorMessage.value = `Failed to get records ${error}. Please, try to re-run the action.`;
359+
errorMessage.value = `Failed to fetch analyze image(s). Please, try to re-run the action.`;
359360
}
360361
}
361362
@@ -388,9 +389,9 @@ async function analyzeFieldsNoImages() {
388389
}
389390
})
390391
} catch (error) {
391-
console.error('Failed to get records:', error);
392+
console.error('Failed to analyze fields:', error);
392393
isError.value = true;
393-
errorMessage.value = `Failed to get records ${error}. Please, try to re-run the action.`;
394+
errorMessage.value = `Failed to analyze fields. Please, try to re-run the action.`;
394395
}
395396
}
396397
@@ -435,12 +436,12 @@ async function saveData() {
435436
} else {
436437
console.error('Error saving data:', res);
437438
isError.value = true;
438-
errorMessage.value = `Failed to save data ${res}. Please, try to re-run the action.`;
439+
errorMessage.value = `Failed to save data. Please, try to re-run the action.`;
439440
}
440441
} catch (error) {
441442
console.error('Error saving data:', error);
442443
isError.value = true;
443-
errorMessage.value = `Failed to save data ${error}. Please, try to re-run the action.`;
444+
errorMessage.value = `Failed to save data. Please, try to re-run the action.`;
444445
} finally {
445446
isLoading.value = false;
446447
}
@@ -462,7 +463,8 @@ async function generateImages() {
462463
} catch (e) {
463464
console.error('Error generating images:', e);
464465
isError.value = true;
465-
errorMessage.value = `Failed to generate images ${e}. Please, try to re-run the action.`;
466+
isCriticalError.value = true;
467+
errorMessage.value = `Failed to generate images. Please, try to re-run the action.`;
466468
}
467469
isAiResponseReceivedImage.value = props.checkboxes.map(() => true);
468470
@@ -472,7 +474,8 @@ async function generateImages() {
472474
if (!res) {
473475
error = 'Error generating images, something went wrong';
474476
isError.value = true;
475-
errorMessage.value = `Failed to generate images ${e}. Please, try to re-run the action.`;
477+
isCriticalError.value = true;
478+
errorMessage.value = `Failed to generate images. Please, try to re-run the action.`;
476479
}
477480
478481
if (error) {

0 commit comments

Comments
 (0)