|
|
@@ -76,24 +76,28 @@ export namespace SessionRetry {
|
|
|
return undefined
|
|
|
}
|
|
|
})
|
|
|
- if (!json || typeof json !== "object") return undefined
|
|
|
- const code = typeof json.code === "string" ? json.code : ""
|
|
|
+ try {
|
|
|
+ if (!json || typeof json !== "object") return undefined
|
|
|
+ const code = typeof json.code === "string" ? json.code : ""
|
|
|
|
|
|
- if (json.type === "error" && json.error?.type === "too_many_requests") {
|
|
|
- return "Too Many Requests"
|
|
|
- }
|
|
|
- if (code.includes("exhausted") || code.includes("unavailable")) {
|
|
|
- return "Provider is overloaded"
|
|
|
- }
|
|
|
- if (json.type === "error" && json.error?.code?.includes("rate_limit")) {
|
|
|
- return "Rate Limited"
|
|
|
- }
|
|
|
- if (
|
|
|
- json.error?.message?.includes("no_kv_space") ||
|
|
|
- (json.type === "error" && json.error?.type === "server_error") ||
|
|
|
- !!json.error
|
|
|
- ) {
|
|
|
- return "Provider Server Error"
|
|
|
+ if (json.type === "error" && json.error?.type === "too_many_requests") {
|
|
|
+ return "Too Many Requests"
|
|
|
+ }
|
|
|
+ if (code.includes("exhausted") || code.includes("unavailable")) {
|
|
|
+ return "Provider is overloaded"
|
|
|
+ }
|
|
|
+ if (json.type === "error" && json.error?.code?.includes("rate_limit")) {
|
|
|
+ return "Rate Limited"
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ json.error?.message?.includes("no_kv_space") ||
|
|
|
+ (json.type === "error" && json.error?.type === "server_error") ||
|
|
|
+ !!json.error
|
|
|
+ ) {
|
|
|
+ return "Provider Server Error"
|
|
|
+ }
|
|
|
+ } catch {
|
|
|
+ return undefined
|
|
|
}
|
|
|
}
|
|
|
}
|