fix(api): surface LLM network errors for WeCom AI replies
CI / verify (pull_request) Has been cancelled
CI / verify (pull_request) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -50,6 +50,14 @@ export class LlmChatClient {
|
|||||||
Authorization: `Bearer ${params.apiKey}`,
|
Authorization: `Bearer ${params.apiKey}`,
|
||||||
},
|
},
|
||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
|
}).catch((err: unknown) => {
|
||||||
|
const cause =
|
||||||
|
err && typeof err === 'object' && 'cause' in err
|
||||||
|
? (err as { cause?: { code?: string; message?: string } }).cause
|
||||||
|
: undefined;
|
||||||
|
const detail = cause?.code || cause?.message || (err instanceof Error ? err.message : String(err));
|
||||||
|
this.logger.warn(`llm chat network error ${url}: ${detail}`);
|
||||||
|
throw new Error(`无法连接语言模型服务(${detail})。请检查 Base URL 是否可从服务器访问,或更换可达的模型网关`);
|
||||||
});
|
});
|
||||||
|
|
||||||
const text = await res.text();
|
const text = await res.text();
|
||||||
|
|||||||
Reference in New Issue
Block a user