From a4c2ed53289988ef9129c96d7205da02646e717e Mon Sep 17 00:00:00 2001 From: icarus Date: Thu, 18 Sep 2025 22:02:42 +0800 Subject: [PATCH] fix(api): update error handling to match new error structure The AgentServerError schema was updated to nest error properties under an 'error' object. This commit aligns the error formatting function with the new schema structure. --- src/renderer/src/types/agent.ts | 8 +++++--- src/renderer/src/utils/api.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/types/agent.ts b/src/renderer/src/types/agent.ts index 49702c20e4..1551612de3 100644 --- a/src/renderer/src/types/agent.ts +++ b/src/renderer/src/types/agent.ts @@ -200,9 +200,11 @@ export const CreateSessionResponseSchema = AgentSessionEntitySchema export type CreateSessionResponse = AgentSessionEntity export const AgentServerErrorSchema = z.object({ - message: z.string(), - type: z.string(), - code: z.string() + error: z.object({ + message: z.string(), + type: z.string(), + code: z.string() + }) }) export type AgentServerError = z.infer diff --git a/src/renderer/src/utils/api.ts b/src/renderer/src/utils/api.ts index 0fa892c131..15129397d5 100644 --- a/src/renderer/src/utils/api.ts +++ b/src/renderer/src/utils/api.ts @@ -75,7 +75,7 @@ export function splitApiKeyString(keyStr: string): string[] { } export const formatAgentServerError = (error: AgentServerError) => - `${t('common.error')}: ${error.code} ${error.message}` + `${t('common.error')}: ${error.error.code} ${error.error.message}` export const formatAxiosError = (error: AxiosError) => { if (!error.response) {