mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
fixed error parsing in mcp
This commit is contained in:
parent
6a73e5bd37
commit
e699b21878
3 changed files with 23 additions and 7 deletions
|
|
@ -21,13 +21,18 @@ export interface RouterFieldsResponse {
|
|||
const routerFieldsKeys = createQueryKeys("routerFields");
|
||||
|
||||
const deriveErrorMessage = (errorData: any): string => {
|
||||
return (
|
||||
const raw =
|
||||
(errorData?.error && (errorData.error.message || errorData.error)) ||
|
||||
errorData?.message ||
|
||||
errorData?.detail ||
|
||||
errorData?.error ||
|
||||
JSON.stringify(errorData)
|
||||
);
|
||||
JSON.stringify(errorData);
|
||||
// Backend often returns { detail: { error: "..." } }; avoid showing [object Object]
|
||||
if (typeof raw === "object" && raw !== null) {
|
||||
const msg = raw.error ?? raw.message;
|
||||
return typeof msg === "string" ? msg : JSON.stringify(raw);
|
||||
}
|
||||
return String(raw);
|
||||
};
|
||||
|
||||
const getRouterFields = async (accessToken: string): Promise<RouterFieldsResponse> => {
|
||||
|
|
|
|||
|
|
@ -305,7 +305,13 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
|
|||
onCreateSuccess(response);
|
||||
}
|
||||
} catch (error) {
|
||||
NotificationsManager.fromBackend("Error creating MCP Server: " + error);
|
||||
const message =
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: typeof error === "object" && error !== null && "error" in error
|
||||
? String((error as { error: unknown }).error)
|
||||
: String(error);
|
||||
NotificationsManager.fromBackend("Error creating MCP Server: " + message);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8690,13 +8690,18 @@ export const perUserAnalyticsCall = async (
|
|||
};
|
||||
|
||||
export const deriveErrorMessage = (errorData: any): string => {
|
||||
return (
|
||||
const raw =
|
||||
(errorData?.error && (errorData.error.message || errorData.error)) ||
|
||||
errorData?.message ||
|
||||
errorData?.detail ||
|
||||
errorData?.error ||
|
||||
JSON.stringify(errorData)
|
||||
);
|
||||
JSON.stringify(errorData);
|
||||
// Backend often returns { detail: { error: "..." } }; avoid showing [object Object]
|
||||
if (typeof raw === "object" && raw !== null) {
|
||||
const msg = raw.error ?? raw.message;
|
||||
return typeof msg === "string" ? msg : JSON.stringify(raw);
|
||||
}
|
||||
return String(raw);
|
||||
};
|
||||
|
||||
export interface LoginRequest {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue