From 9d856ca69486295b4e0042a64ada65250d6d3c60 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vega Date: Thu, 5 Dec 2024 15:56:40 +0100 Subject: [PATCH] handle errors in callVariant --- agenta-web/src/services/api.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/agenta-web/src/services/api.ts b/agenta-web/src/services/api.ts index 93bdd70a0d..4031e76103 100644 --- a/agenta-web/src/services/api.ts +++ b/agenta-web/src/services/api.ts @@ -151,7 +151,11 @@ export async function callVariant( return response }) .catch(async (error) => { - console.log("Unsecure call to LLM App failed:", error?.status) + console.log("Unsecure call to LLM App failed:", error) + + if (error?.response?.status !== 401) { + throw error + } let response = await axios .post(secure_url, requestBody, { @@ -163,7 +167,9 @@ export async function callVariant( return response }) .catch((error) => { - console.log("Secure call to LLM App failed:", error?.status) + console.log("Secure call to LLM App failed:", error) + + throw error }) return response @@ -200,7 +206,11 @@ export const fetchVariantParametersFromOpenAPI = async ( return response }) .catch(async (error) => { - console.log("Unsecure call to LLM App failed:", error?.status) + console.log("Unsecure call to LLM App failed:", error) + + if (error?.response?.status !== 401) { + throw error + } let response = await axios .get(secure_url, { @@ -211,7 +221,9 @@ export const fetchVariantParametersFromOpenAPI = async ( return response }) .catch((error) => { - console.log("Secure call to LLM App failed:", error?.status) + console.log("Secure call to LLM App failed:", error) + + throw error }) return response