MCPcopy Create free account
hub / github.com/apache/maka / generalizedErrorMessage

Function generalizedErrorMessage

packages/core/src/redaction.ts:185–202  ·  view source on GitHub ↗
(error: unknown, fallback = 'Operation failed')

Source from the content-addressed store, hash-verified

183}
184
185export function generalizedErrorMessage(error: unknown, fallback = 'Operation failed'): string {
186 const message = error instanceof Error ? error.message : String(error);
187 const redacted = redactSecrets(message);
188 const lower = redacted.toLowerCase();
189 if (lower.includes('timeout')) return 'Request timed out';
190 if (lower.includes('429') || lower.includes('rate')) return 'Rate limit exceeded';
191 if (lower.includes('401') || lower.includes('403') || isAuthenticationErrorText(lower))
192 return 'Authentication failed';
193 if (lower.includes('5') && /\b5\d\d\b/.test(lower)) return 'Provider returned an error';
194 if (
195 lower.includes('network') ||
196 lower.includes('fetch') ||
197 lower.includes('econn') ||
198 lower.includes('enotfound')
199 )
200 return 'Network error';
201 return fallback;
202}
203
204/**
205 * Chinese-locale companion to `generalizedErrorMessage()` (PR110b

Callers 15

toggleKeepSystemAwakeFunction · 0.90
normalizeModelFailureFunction · 0.90
explainErrorFunction · 0.90
fetchProviderModelsFunction · 0.90
recordToolInvocationFunction · 0.90
recordLlmCallFunction · 0.90
startMethod · 0.90
sendMessageMethod · 0.90
sendMessageMethod · 0.90

Calls 3

redactSecretsFunction · 0.70
testMethod · 0.65

Tested by

no test coverage detected