diff --git a/agenta-cli/agenta/sdk/decorators/routing.py b/agenta-cli/agenta/sdk/decorators/routing.py index 32b0d29bfb..ae5ccd7f78 100644 --- a/agenta-cli/agenta/sdk/decorators/routing.py +++ b/agenta-cli/agenta/sdk/decorators/routing.py @@ -394,7 +394,7 @@ def handle_failure(self, error: Exception): log.warning(format_exc().strip("\n")) log.warning("--------------------------------------------------") - status_code = error.status_code if hasattr(error, "status_code") else 500 + status_code = 500 message = str(error) stacktrace = format_exception(error, value=error, tb=error.__traceback__) # type: ignore detail = {"message": message, "stacktrace": stacktrace} 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