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.
This commit is contained in:
icarus 2025-09-18 22:02:42 +08:00
parent 934cc0dd33
commit a4c2ed5328
2 changed files with 6 additions and 4 deletions

View File

@ -200,9 +200,11 @@ export const CreateSessionResponseSchema = AgentSessionEntitySchema
export type CreateSessionResponse = AgentSessionEntity export type CreateSessionResponse = AgentSessionEntity
export const AgentServerErrorSchema = z.object({ export const AgentServerErrorSchema = z.object({
message: z.string(), error: z.object({
type: z.string(), message: z.string(),
code: z.string() type: z.string(),
code: z.string()
})
}) })
export type AgentServerError = z.infer<typeof AgentServerErrorSchema> export type AgentServerError = z.infer<typeof AgentServerErrorSchema>

View File

@ -75,7 +75,7 @@ export function splitApiKeyString(keyStr: string): string[] {
} }
export const formatAgentServerError = (error: AgentServerError) => 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) => { export const formatAxiosError = (error: AxiosError) => {
if (!error.response) { if (!error.response) {