浏览代码

fix: #1611 show corret message when can not query usage

Yidadaa 1 年之前
父节点
当前提交
a524a60c46
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      app/client/platforms/openai.ts

+ 5 - 1
app/client/platforms/openai.ts

@@ -189,10 +189,14 @@ export class ChatGPTApi implements LLMApi {
       }),
     ]);
 
-    if (!used.ok || !subs.ok || used.status === 401) {
+    if (used.status === 401) {
       throw new Error(Locale.Error.Unauthorized);
     }
 
+    if (!used.ok || !subs.ok) {
+      throw new Error("Failed to query usage from openai");
+    }
+
     const response = (await used.json()) as {
       total_usage?: number;
       error?: {