From 0b7e29e5d0602f64be0e5db6748ca3811b9fbbcb Mon Sep 17 00:00:00 2001 From: Nic D Date: Wed, 25 Feb 2026 14:08:04 -0500 Subject: [PATCH] fix(chatbot): made error handling more explicit in replies. --- quasar.config.ts | 8 ++++++-- src/i18n/en-ca/index.ts | 8 +++++--- src/i18n/fr-ca/index.ts | 8 +++++--- src/stores/chatbot-store.ts | 7 ++++--- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/quasar.config.ts b/quasar.config.ts index 8e9ee05..205b2f3 100644 --- a/quasar.config.ts +++ b/quasar.config.ts @@ -41,7 +41,7 @@ export default defineConfig((ctx) => { build: { target: { browser: [ 'es2022', 'firefox115', 'chrome115', 'safari14' ], - node: 'node20' + node: 'node20', }, typescript: { @@ -66,7 +66,11 @@ export default defineConfig((ctx) => { // polyfillModulePreload: true, // distDir - // extendViteConf (viteConf) {}, + extendViteConf: (_config) => ({ + optimizeDeps: { + exclude: ['tesseract.js'] + } + }), // viteVuePluginOptions: {}, vitePlugins: [ diff --git a/src/i18n/en-ca/index.ts b/src/i18n/en-ca/index.ts index 4f4be80..9af138a 100644 --- a/src/i18n/en-ca/index.ts +++ b/src/i18n/en-ca/index.ts @@ -5,9 +5,11 @@ export default { chat_placeholder: "Enter a Message", chat_thinking: "Thinking...", error: { - NO_REPLY_RECEIVED: "encountered an error while waiting for chatbot to reply", - SEND_MESSAGE_FAILED: "unable to send message to chatbot", - GENERIC_RESPONSE_ERROR: "An error was encountered while waiting for the chatbot to reply, please try again.", + NO_REPLY_RECEIVED: "FRONTEND ERROR: the backend did not include a message text in the response", + NO_DATA_RECEIVED: "BACKEND ERROR: the backend did not receive any data from the AI agent", + NO_OUTPUT_RECEIVED: "BACKEND ERROR: the backend received data, but no output, from the AI agent", + SEND_MESSAGE_FAILED: "FRONTEND ERROR: Your message could not send or was timed out", + GENERIC_RESPONSE_ERROR: "BACKEND ERROR: An unexpected error occured while waiting for the backend to respond", }, }, diff --git a/src/i18n/fr-ca/index.ts b/src/i18n/fr-ca/index.ts index 0252bb6..a76fdd9 100644 --- a/src/i18n/fr-ca/index.ts +++ b/src/i18n/fr-ca/index.ts @@ -5,9 +5,11 @@ export default { chat_placeholder: "Entrez un Message", chat_thinking: "Réflexion en cours...", error: { - NO_REPLY_RECEIVED: "Une erreur est survenu lors de la réception de la réponse du chatbot", - SEND_MESSAGE_FAILED: "Une erreur est survenue lors de l'envoi de votre message", - GENERIC_RESPONSE_ERROR: "Le chatbot ne réponds pas pour le moment, veuillez réessayer.", + NO_REPLY_RECEIVED: "ERREUR FRONTEND: Le frontend n'a pas recu de message de l'IA dans la réponse du backend", + NO_DATA_RECEIVED: "ERREUR BACKEND: L'agent IA n'a pas inclu de data dans sa réponse au backend", + NO_OUTPUT_RECEIVED: "ERREUR BACKEND: L'agent IA a inclu du data, mais pas de output, dans sa réponse au backend", + SEND_MESSAGE_FAILED: "ERREUR FRONTEND: Une erreur est survenue lors de l'envoi de votre message, ou la connexion a été perdu", + GENERIC_RESPONSE_ERROR: "ERREUR BACKEND: Une erreur est survenu lors de la réception de la réponse du AI", }, }, diff --git a/src/stores/chatbot-store.ts b/src/stores/chatbot-store.ts index b0fc645..54600f9 100644 --- a/src/stores/chatbot-store.ts +++ b/src/stores/chatbot-store.ts @@ -16,17 +16,18 @@ export const useChatbotStore = defineStore("chatbot", () => { try { const chatbot_response = await chatbotService.sendChatMessage(user_message, current_page_context.value); - if (chatbot_response) { + + if (chatbot_response.text) { last_chatbot_message.text = chatbot_response.text; last_chatbot_message.isThinking = false; } else { last_chatbot_message.text = 'chatbot.error.NO_REPLY_RECEIVED'; last_chatbot_message.isThinking = false; } - } - catch (error) { + } catch (error) { last_chatbot_message.text = 'chatbot.error.SEND_MESSAGE_FAILED'; last_chatbot_message.isThinking = false; + console.error('error sending message: ', error); } };