(error: unknown, providerName: string)
| 23 | * remediation path. |
| 24 | */ |
| 25 | export function mapOAuthTokenError(error: unknown, providerName: string): KimiError | undefined { |
| 26 | if (error instanceof OAuthUnauthorizedError) { |
| 27 | return new KimiError( |
| 28 | ErrorCodes.AUTH_LOGIN_REQUIRED, |
| 29 | `OAuth provider "${providerName}" requires login before it can be used.`, |
| 30 | { cause: error }, |
| 31 | ); |
| 32 | } |
| 33 | if (error instanceof OAuthConnectionError || error instanceof RetryableRefreshError) { |
| 34 | return new KimiError( |
| 35 | ErrorCodes.PROVIDER_CONNECTION_ERROR, |
| 36 | `OAuth provider "${providerName}" failed to fetch an access token: ${error.message}`, |
| 37 | { cause: error }, |
| 38 | ); |
| 39 | } |
| 40 | return undefined; |
| 41 | } |
no outgoing calls
no test coverage detected