Browse Source

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

Yidadaa 1 year ago
parent
commit
a524a60c46
1 changed files with 5 additions and 1 deletions
  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);
       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 {
     const response = (await used.json()) as {
       total_usage?: number;
       total_usage?: number;
       error?: {
       error?: {