fix(model-fallback): retry forbidden provider errors
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -33,16 +33,15 @@ export function extractErrorName(error: unknown): string | undefined {
|
||||
export function extractErrorMessage(error: unknown): string | undefined {
|
||||
if (!error) return undefined
|
||||
if (typeof error === "string") return error
|
||||
if (error instanceof Error) return error.message
|
||||
|
||||
if (isRecord(error)) {
|
||||
const dataRaw = error["data"]
|
||||
const candidates: unknown[] = [
|
||||
error,
|
||||
dataRaw,
|
||||
error["error"],
|
||||
isRecord(dataRaw) ? (dataRaw as Record<string, unknown>)["error"] : undefined,
|
||||
error["error"],
|
||||
error["cause"],
|
||||
error,
|
||||
]
|
||||
|
||||
for (const candidate of candidates) {
|
||||
@@ -57,6 +56,8 @@ export function extractErrorMessage(error: unknown): string | undefined {
|
||||
}
|
||||
}
|
||||
|
||||
if (error instanceof Error) return error.message
|
||||
|
||||
try {
|
||||
return JSON.stringify(error)
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user