MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / isApiKeyError

Function isApiKeyError

src/utils/errors.ts:145–175  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

143}
144
145export function isApiKeyError(error: unknown): boolean {
146 if (error instanceof ApiKeyMissingError) {
147 return true;
148 }
149
150 if (error instanceof Error) {
151 const message = error.message.toLowerCase();
152
153 // Common API key error patterns
154 if (
155 message.includes('api key') ||
156 message.includes('apikey') ||
157 message.includes('authentication') ||
158 message.includes('unauthorized') ||
159 message.includes('invalid_api_key') ||
160 message.includes('incorrect api key')
161 ) {
162 return true;
163 }
164
165 // Check for 401 status
166 if ('response' in (error as any)) {
167 const response = (error as any).response;
168 if (response?.status === 401) {
169 return true;
170 }
171 }
172 }
173
174 return false;
175}
176
177export function getSuggestedModels(
178 provider: string,

Callers 1

formatUserFriendlyErrorFunction · 0.70

Calls 2

toLowerCaseMethod · 0.80
includesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…