(error: any)
| 54 | |
| 55 | // Anthropic errors are stringfied JSON objects, format them to be more user friendly |
| 56 | export function formatAnthropicError(error: any): string { |
| 57 | const prefix = "Anthropic:"; |
| 58 | |
| 59 | if (error instanceof Error) { |
| 60 | if ( |
| 61 | error.message.includes("authentication_error") && |
| 62 | error.message.includes("invalid x-api-key") |
| 63 | ) { |
| 64 | return `${prefix} Invalid API key`; |
| 65 | } |
| 66 | |
| 67 | return `${prefix} ${error.message}`; |
| 68 | } |
| 69 | |
| 70 | return `${prefix} ${String(error)}`; |
| 71 | } |
no outgoing calls
no test coverage detected