MCPcopy
hub / github.com/claude-code-best/claude-code / shortErrorStack

Function shortErrorStack

src/utils/errors.ts:161–171  ·  view source on GitHub ↗
(e: unknown, maxFrames = 5)

Source from the content-addressed store, hash-verified

159 * waste context tokens. Keep the full stack in debug logs instead.
160 */
161export function shortErrorStack(e: unknown, maxFrames = 5): string {
162 if (!(e instanceof Error)) return String(e)
163 if (!e.stack) return e.message
164 // V8/Bun stack format: "Name: message\n at frame1\n at frame2..."
165 // First line is the message; subsequent " at " lines are frames.
166 const lines = e.stack.split('\n')
167 const header = lines[0] ?? e.message
168 const frames = lines.slice(1).filter(l => l.trim().startsWith('at '))
169 if (frames.length <= maxFrames) return e.stack
170 return [header, ...frames.slice(0, maxFrames)].join('\n')
171}
172
173/**
174 * True if the error means the path is missing, inaccessible, or

Callers 2

errors.test.tsFile · 0.90
logErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected