From 0ee357d03e779a467a9ff5bd472f99aae04cc309 Mon Sep 17 00:00:00 2001 From: josc146 Date: Thu, 8 Aug 2024 15:04:25 +0800 Subject: [PATCH] minor improvement --- src/services/apis/chatgpt-web.mjs | 2 +- src/services/apis/moonshot-web.mjs | 3 +++ src/services/clients/claude/index.mjs | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/services/apis/chatgpt-web.mjs b/src/services/apis/chatgpt-web.mjs index 75e21b14..8684e9cd 100644 --- a/src/services/apis/chatgpt-web.mjs +++ b/src/services/apis/chatgpt-web.mjs @@ -397,7 +397,7 @@ export async function generateAnswersWithChatgptWebApi(port, question, session, function handleMessage(data) { if (data.error) { - throw new Error(data.error) + throw new Error(JSON.stringify(data.error)) } if (data.conversation_id) session.conversationId = data.conversation_id diff --git a/src/services/apis/moonshot-web.mjs b/src/services/apis/moonshot-web.mjs index a9cfcbfa..699ff374 100644 --- a/src/services/apis/moonshot-web.mjs +++ b/src/services/apis/moonshot-web.mjs @@ -405,6 +405,9 @@ export class Conversation { console.debug('json error', error) return } + if (parsed.error) { + throw new Error(message) + } if (parsed.event === 'cmpl' && parsed.text) fullResponse += parsed.text const PROGRESS_OBJECT = { ...parsed, diff --git a/src/services/clients/claude/index.mjs b/src/services/clients/claude/index.mjs index 0da62f30..48f2504e 100644 --- a/src/services/clients/claude/index.mjs +++ b/src/services/clients/claude/index.mjs @@ -610,6 +610,9 @@ export class Conversation { console.debug('json error', error) return } + if (parsed.error) { + throw new Error(message) + } if (parsed.completion) fullResponse += parsed.completion const PROGRESS_OBJECT = { ...parsed,