mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-09 14:59:27 +08:00
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:
parent
934cc0dd33
commit
a4c2ed5328
@ -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>
|
||||||
|
|||||||
@ -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) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user