From 402b8c429e84b43ce6ca0112a601d4b912b5ff26 Mon Sep 17 00:00:00 2001 From: Crumb Owl Date: Sun, 6 Jul 2025 19:15:45 +0000 Subject: [PATCH] ProductBarcode: improve error handling in BarcodeModal --- frontend/components/Item/BarcodeModal.vue | 27 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/frontend/components/Item/BarcodeModal.vue b/frontend/components/Item/BarcodeModal.vue index d0b3bf2d..6b75a153 100644 --- a/frontend/components/Item/BarcodeModal.vue +++ b/frontend/components/Item/BarcodeModal.vue @@ -78,7 +78,7 @@
- +
@@ -152,13 +152,28 @@ async function retrieveProductInfo(barcode: string) { products.value = null; searching.value = true; - const result = await api.products.searchFromBarcode(barcode); - searching.value = false; - if(result.error) - return + if (!barcode || barcode.trim().length === 0) { + console.error('Invalid barcode provided'); + return; + } - products.value = result.data; + try { + const result = await api.products.searchFromBarcode(barcode.trim()); + if(result.error) + { + console.error('API Error:', result.error); + return; + } + else + { + products.value = result.data; + } + } catch (error) { + console.error('Failed to retrieve product info:', error); + } finally { + searching.value = false; + } } function extractValue(data: TableData, value: string) {