MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / shortErrorStack

Function shortErrorStack

source code/utils/errors.ts:163–173  ·  view source on GitHub ↗
(e: unknown, maxFrames = 5)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected