Skip to content

Commit

Permalink
handle errors in callVariant
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-agenta committed Dec 5, 2024
1 parent e4c1b4e commit 9d856ca
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions agenta-web/src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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
Expand Down Expand Up @@ -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, {
Expand All @@ -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
Expand Down

0 comments on commit 9d856ca

Please sign in to comment.