Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

replace text error with json error

tanjiro06ee35f74cb3
diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx
index 93ae040c868..81829eef7cc 100644
--- a/ui/litellm-dashboard/src/components/networking.tsx
+++ b/ui/litellm-dashboard/src/components/networking.tsx
@@ -368,12 +368,13 @@ export const modelCreateCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- const errorMsg = errorData || "Network response was not ok";
- message.error(errorMsg);
- throw new Error(errorMsg);
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
@@ -409,11 +410,13 @@ export const modelSettingsCall = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
//message.info("Received model data");
return data;
@@ -442,12 +445,13 @@ export const modelDeleteCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -483,11 +487,12 @@ export const budgetDeleteCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -518,12 +523,13 @@ export const budgetCreateCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -557,12 +563,13 @@ export const budgetUpdateCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -593,12 +600,13 @@ export const invitationCreateCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -632,12 +640,13 @@ export const invitationClaimCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -667,11 +676,13 @@ export const alertingSettingsCall = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
//message.info("Received model data");
return data;
@@ -889,11 +900,13 @@ export const keyDeleteCall = async (accessToken: String, user_key: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
//message.success("API Key Deleted");
@@ -925,11 +938,13 @@ export const userDeleteCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
//message.success("User(s) Deleted");
@@ -956,10 +971,12 @@ export const teamDeleteCall = async (accessToken: String, teamID: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
return data;
@@ -1050,11 +1067,13 @@ export const userListCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = (await response.json()) as UserListResponse;
console.log("/user/list API Response:", data);
return data;
@@ -1111,11 +1130,13 @@ export const userInfoCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -1144,11 +1165,13 @@ export const teamInfoCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -1216,11 +1239,13 @@ export const v2TeamListCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("/v2/team/list API Response:", data);
return data;
@@ -1276,11 +1301,13 @@ export const teamListCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("/team/list API Response:", data);
return data;
@@ -1309,11 +1336,13 @@ export const availableTeamListCall = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("/team/available_teams API Response:", data);
return data;
@@ -1339,11 +1368,13 @@ export const organizationListCall = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -1373,11 +1404,13 @@ export const organizationInfoCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -1421,12 +1454,13 @@ export const organizationCreateCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -1459,11 +1493,12 @@ export const organizationUpdateCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("Update Team Response:", data);
return data;
@@ -1530,11 +1565,13 @@ export const transformRequestCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -1575,11 +1612,13 @@ export const userDailyActivityCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -1624,11 +1663,13 @@ export const tagDailyActivityCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -1674,11 +1715,13 @@ export const teamDailyActivityCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -1704,11 +1747,13 @@ export const getTotalSpendCall = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
// Handle success - you might want to update some state or UI based on the created key
@@ -1736,11 +1781,13 @@ export const getOnboardingCredentials = async (inviteUUID: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
// Handle success - you might want to update some state or UI based on the created key
@@ -1774,10 +1821,12 @@ export const claimOnboardingToken = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
return data;
@@ -1808,11 +1857,13 @@ export const regenerateKeyCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("Regenerate key Response:", data);
return data;
@@ -1898,10 +1949,13 @@ export const modelInfoV1Call = async (accessToken: String, modelId: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("modelInfoV1Call:", data);
return data;
@@ -1941,10 +1995,13 @@ export const modelHubCall = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("modelHubCall:", data);
//message.info("Received model data");
@@ -1972,10 +2029,13 @@ export const getAllowedIPs = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- throw new Error(`Network response was not ok: ${errorData}`);
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("getAllowedIPs:", data);
return data.data; // Assuming the API returns { data: [...] }
@@ -2002,10 +2062,13 @@ export const addAllowedIP = async (accessToken: String, ip: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- throw new Error(`Network response was not ok: ${errorData}`);
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("addAllowedIP:", data);
return data;
@@ -2032,10 +2095,13 @@ export const deleteAllowedIP = async (accessToken: String, ip: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- throw new Error(`Network response was not ok: ${errorData}`);
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("deleteAllowedIP:", data);
return data;
@@ -2073,10 +2139,12 @@ export const modelMetricsCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
// message.info("Received model data");
return data;
@@ -2112,10 +2180,12 @@ export const streamingModelMetricsCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
// message.info("Received model data");
return data;
@@ -2157,10 +2227,12 @@ export const modelMetricsSlowResponsesCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
// message.info("Received model data");
return data;
@@ -2201,10 +2273,12 @@ export const modelExceptionsCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
// message.info("Received model data");
return data;
@@ -2227,10 +2301,12 @@ export const updateUsefulLinksCall = async (accessToken: String, useful_links: R
body: JSON.stringify({ useful_links: useful_links }),
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
return await response.json();
} catch (error) {
console.error("Failed to create key:", error);
@@ -2281,11 +2357,13 @@ export const modelAvailableCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
//message.info("Received model data");
return data;
@@ -2310,11 +2388,13 @@ export const keySpendLogsCall = async (accessToken: String, token: String) => {
},
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
return data;
@@ -2338,11 +2418,13 @@ export const teamSpendLogsCall = async (accessToken: String) => {
},
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
return data;
@@ -2381,10 +2463,13 @@ export const tagsSpendLogsCall = async (
},
});
if (!response.ok) {
- const errorData = await response.text();
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
return data;
@@ -2409,10 +2494,13 @@ export const allTagNamesCall = async (accessToken: String) => {
},
});
if (!response.ok) {
- const errorData = await response.text();
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
return data;
@@ -2437,10 +2525,13 @@ export const allEndUsersCall = async (accessToken: String) => {
},
});
if (!response.ok) {
- const errorData = await response.text();
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
return data;
@@ -2474,10 +2565,12 @@ export const userFilterUICall = async (
},
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
return await response.json();
} catch (error) {
console.error("Failed to create key:", error);
@@ -2510,11 +2603,13 @@ export const userSpendLogsCall = async (
},
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
//message.success("Spend Logs received");
@@ -2571,11 +2666,13 @@ export const uiSpendLogsCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("Spend Logs Response:", data);
return data;
@@ -2600,11 +2697,13 @@ export const adminSpendLogsCall = async (accessToken: String) => {
},
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
//message.success("Spend Logs received");
@@ -2630,11 +2729,13 @@ export const adminTopKeysCall = async (accessToken: String) => {
},
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
//message.success("Spend Logs received");
@@ -2681,11 +2782,13 @@ export const adminTopEndUsersCall = async (
const response = await fetch(url, requestOptions);
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
//message.success("Top End users received");
@@ -2725,11 +2828,13 @@ export const adminspendByProvider = async (
const response = await fetch(url, requestOptions);
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
return data;
@@ -2763,9 +2868,12 @@ export const adminGlobalActivity = async (
const response = await fetch(url, requestOptions);
if (!response.ok) {
- const errorData = await response.text();
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
return data;
@@ -2799,9 +2907,12 @@ export const adminGlobalCacheActivity = async (
const response = await fetch(url, requestOptions);
if (!response.ok) {
- const errorData = await response.text();
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
return data;
@@ -2835,9 +2946,12 @@ export const adminGlobalActivityPerModel = async (
const response = await fetch(url, requestOptions);
if (!response.ok) {
- const errorData = await response.text();
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
return data;
@@ -2876,9 +2990,12 @@ export const adminGlobalActivityExceptions = async (
const response = await fetch(url, requestOptions);
if (!response.ok) {
- const errorData = await response.text();
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
return data;
@@ -2917,9 +3034,12 @@ export const adminGlobalActivityExceptionsPerDeployment = async (
const response = await fetch(url, requestOptions);
if (!response.ok) {
- const errorData = await response.text();
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
return data;
@@ -2944,11 +3064,13 @@ export const adminTopModelsCall = async (accessToken: String) => {
},
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
//message.success("Top Models received");
@@ -3160,11 +3282,13 @@ export const keyListCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("/team/list API Response:", data);
return data;
@@ -3187,11 +3311,13 @@ export const spendUsersCall = async (accessToken: String, userID: String) => {
},
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
return data;
@@ -3225,10 +3351,12 @@ export const userRequestModelCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
//message.success("");
@@ -3255,10 +3383,12 @@ export const userGetRequesedtModelsCall = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
//message.success("");
@@ -3313,11 +3443,13 @@ export const userDailyActivityAggregatedCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -3344,10 +3476,12 @@ export const userGetAllUsersCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
//message.success("Got all users");
@@ -3373,9 +3507,12 @@ export const getPossibleUserRoles = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = (await response.json()) as Record<
string,
Record<string, string>
@@ -3417,12 +3554,13 @@ export const teamCreateCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -3462,12 +3600,13 @@ export const credentialCreateCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -3495,11 +3634,13 @@ export const credentialListCall = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("/credentials API Response:", data);
return data;
@@ -3535,11 +3676,13 @@ export const credentialGetCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("/credentials API Response:", data);
return data;
@@ -3568,10 +3711,12 @@ export const credentialDeleteCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
return data;
@@ -3614,12 +3759,13 @@ export const credentialUpdateCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -4001,12 +4147,13 @@ export const teamMemberDeleteCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -4082,12 +4229,13 @@ export const organizationMemberDeleteCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -4121,12 +4269,13 @@ export const organizationMemberUpdateCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("API Response:", data);
return data;
@@ -4160,12 +4309,13 @@ export const userUpdateUserCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = (await response.json()) as {
user_id: string;
data: UserInfo;
@@ -4227,12 +4377,13 @@ export const userBulkUpdateUserCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = (await response.json()) as {
results: Array<{
user_id?: string;
@@ -4278,11 +4429,13 @@ export const PredictedSpendLogsCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log(data);
//message.success("Predicted Logs received");
@@ -4382,11 +4535,13 @@ export const getBudgetList = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
//message.info("Received model data");
return data;
@@ -4415,11 +4570,13 @@ export const getBudgetSettings = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
//message.info("Received model data");
return data;
@@ -4453,11 +4610,13 @@ export const getCallbacksCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
//message.info("Received model data");
return data;
@@ -4484,11 +4643,13 @@ export const getGeneralSettingsCall = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
//message.info("Received model data");
return data;
@@ -4515,11 +4676,13 @@ export const getPassThroughEndpointsCall = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
//message.info("Received model data");
return data;
@@ -4549,10 +4712,13 @@ export const getConfigFieldSetting = async (
});
if (!response.ok) {
- const errorData = await response.text();
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
// Handle success - you might want to update some state or UI based on the created key
@@ -4587,11 +4753,13 @@ export const updatePassThroughFieldSetting = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
//message.info("Received model data");
message.success("Successfully updated value!");
@@ -4628,11 +4796,13 @@ export const createPassThroughEndpoint = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
//message.info("Received model data");
return data;
@@ -4669,11 +4839,13 @@ export const updateConfigFieldSetting = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
//message.info("Received model data");
message.success("Successfully updated value!");
@@ -4709,11 +4881,13 @@ export const deleteConfigFieldSetting = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
message.success("Field reset on proxy");
return data;
@@ -4743,11 +4917,13 @@ export const deletePassThroughEndpointsCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
//message.info("Received model data");
return data;
@@ -4781,11 +4957,13 @@ export const setCallbacksCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
//message.info("Received model data");
return data;
@@ -4813,11 +4991,13 @@ export const healthCheckCall = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
//message.info("Received model data");
return data;
@@ -4849,10 +5029,13 @@ export const individualModelHealthCheckCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- throw new Error(errorData || "Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -4991,10 +5174,13 @@ export const getProxyUISettings = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
//message.info("Received model data");
return data;
@@ -5019,11 +5205,13 @@ export const getGuardrailsList = async (accessToken: String) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -5046,11 +5234,13 @@ export const getPromptsList = async (accessToken: String) : Promise<ListPromptsR
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -5071,11 +5261,13 @@ export const getPromptInfo = async (accessToken: String, promptId: string): Prom
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -5101,11 +5293,13 @@ export const createPromptCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -5132,11 +5326,13 @@ export const updatePromptCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -5161,11 +5357,13 @@ export const deletePromptCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -5195,11 +5393,13 @@ export const convertPromptFileToJson = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
return await response.json();
} catch (error) {
console.error("Failed to convert prompt file:", error);
@@ -5225,11 +5425,13 @@ export const patchPromptCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -5293,11 +5495,13 @@ export const uiSpendLogDetailsCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("Fetched log details:", data);
return data;
@@ -5325,11 +5529,13 @@ export const getInternalUserSettings = async (accessToken: string) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("Fetched SSO settings:", data);
return data;
@@ -5394,11 +5600,13 @@ export const fetchMCPServers = async (accessToken: string) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("Fetched MCP servers:", data);
return data;
@@ -5426,11 +5634,13 @@ export const fetchMCPAccessGroups = async (accessToken: string) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("Fetched MCP access groups:", data);
return data.access_groups || [];
@@ -5463,10 +5673,10 @@ export const createMCPServer = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- console.error("Error response from the server:", errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
const data = await response.json();
@@ -5497,10 +5707,12 @@ export const updateMCPServer = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
return await response.json();
} catch (error) {
console.error("Failed to update MCP server:", error);
@@ -5525,10 +5737,12 @@ export const deleteMCPServer = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
} catch (error) {
console.error("Failed to delete key:", error);
throw error;
@@ -5847,11 +6061,13 @@ export const getDefaultTeamSettings = async (accessToken: string) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("Fetched default team settings:", data);
return data;
@@ -5883,11 +6099,13 @@ export const updateDefaultTeamSettings = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("Updated default team settings:", data);
message.success("Default team settings updated successfully");
@@ -5916,11 +6134,13 @@ export const getTeamPermissionsCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("Team permissions response:", data);
return data;
@@ -5953,11 +6173,13 @@ export const teamPermissionsUpdateCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("Team permissions response:", data);
return data;
@@ -5988,11 +6210,13 @@ export const sessionSpendLogsCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -6430,11 +6654,13 @@ export const getSSOSettings = async (accessToken: string) => {
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("Fetched SSO configuration:", data);
return data;
@@ -6466,11 +6692,13 @@ export const updateSSOSettings = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
console.log("Updated SSO configuration:", data);
return data;
@@ -6513,11 +6741,13 @@ export const uiAuditLogsCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -6586,11 +6816,13 @@ export const updatePassThroughEndpoint = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
message.success("Pass through endpoint updated successfully");
return data;
@@ -6618,11 +6850,13 @@ export const getPassThroughEndpointInfo = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
const endpoints = data["endpoints"];
@@ -6661,11 +6895,13 @@ export const deleteCallback = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -6893,11 +7129,13 @@ export const userAgentAnalyticsCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -6956,11 +7194,13 @@ export const tagDauCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -7018,11 +7258,13 @@ export const tagWauCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -7080,11 +7322,13 @@ export const tagMauCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -7113,11 +7357,13 @@ export const tagDistinctCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -7174,11 +7420,13 @@ export const userAgentSummaryCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -7227,11 +7475,13 @@ export const perUserAnalyticsCall = async (
});
if (!response.ok) {
- const errorData = await response.text();
- handleError(errorData);
- throw new Error("Network response was not ok");
+ const errorData = await response.json();
+ const errorMessage = deriveErrorMessage(errorData);
+ handleError(errorMessage);
+ throw new Error(errorMessage);
}
+
const data = await response.json();
return data;
} catch (error) {
@@ -7240,3 +7490,10 @@ export const perUserAnalyticsCall = async (
}
};
+const deriveErrorMessage = (errorData: any): string => {
+ return (errorData?.error && (errorData.error.message || errorData.error)) ||
+ errorData?.message ||
+ errorData?.detail ||
+ errorData?.error ||
+ JSON.stringify(errorData);
+};