MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / extractErrorMessage

Function extractErrorMessage

cli/src/utils/error-handling.ts:16–30  ·  view source on GitHub ↗
(error: unknown, fallback: string)

Source from the content-addressed store, hash-verified

14
15// Normalize unknown errors to a user-facing string.
16const extractErrorMessage = (error: unknown, fallback: string): string => {
17 if (typeof error === 'string') {
18 return error
19 }
20 if (error instanceof Error && error.message) {
21 return error.message + (error.stack ? `\n\n${error.stack}` : '')
22 }
23 if (error && typeof error === 'object' && 'message' in error) {
24 const candidate = (error as { message: unknown }).message
25 if (typeof candidate === 'string' && candidate.length > 0) {
26 return candidate
27 }
28 }
29 return fallback
30}
31
32/**
33 * Check if an error indicates the user is out of credits.

Callers 1

createErrorMessageFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected