(error: unknown)
| 96 | } |
| 97 | |
| 98 | export function isModelNotFoundError(error: unknown): boolean { |
| 99 | if (error instanceof ModelNotFoundError) { |
| 100 | return true; |
| 101 | } |
| 102 | |
| 103 | if (error instanceof Error) { |
| 104 | const message = error.message.toLowerCase(); |
| 105 | |
| 106 | // OpenAI error patterns |
| 107 | if ( |
| 108 | message.includes('model') && |
| 109 | (message.includes('not found') || |
| 110 | message.includes('does not exist') || |
| 111 | message.includes('invalid model')) |
| 112 | ) { |
| 113 | return true; |
| 114 | } |
| 115 | |
| 116 | // Anthropic error patterns |
| 117 | if ( |
| 118 | message.includes('model') && |
| 119 | (message.includes('not found') || message.includes('invalid')) |
| 120 | ) { |
| 121 | return true; |
| 122 | } |
| 123 | |
| 124 | // Check for 404 status in axios/fetch errors |
| 125 | if ( |
| 126 | 'status' in (error as any) && |
| 127 | (error as any).status === 404 && |
| 128 | message.includes('model') |
| 129 | ) { |
| 130 | return true; |
| 131 | } |
| 132 | |
| 133 | // Check for response status |
| 134 | if ('response' in (error as any)) { |
| 135 | const response = (error as any).response; |
| 136 | if (response?.status === 404) { |
| 137 | return true; |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | return false; |
| 143 | } |
| 144 | |
| 145 | export function isApiKeyError(error: unknown): boolean { |
| 146 | if (error instanceof ApiKeyMissingError) { |
no test coverage detected
searching dependent graphs…