( errorType: StreamErrorType, errorMessage: string )
| 143 | const API_KEY_ERROR_HINTS = ["api key", "api_key", "anthropic_api_key"]; |
| 144 | |
| 145 | export const coerceStreamErrorTypeForMessage = ( |
| 146 | errorType: StreamErrorType, |
| 147 | errorMessage: string |
| 148 | ): StreamErrorType => { |
| 149 | const loweredMessage = errorMessage.toLowerCase(); |
| 150 | if (API_KEY_ERROR_HINTS.some((hint) => loweredMessage.includes(hint))) { |
| 151 | return "authentication"; |
| 152 | } |
| 153 | |
| 154 | return errorType; |
| 155 | }; |
| 156 | export const createStreamErrorMessage = (payload: StreamErrorPayload): StreamErrorMessage => ({ |
| 157 | type: "stream-error", |
| 158 | messageId: payload.messageId, |
no outgoing calls
no test coverage detected