MCPcopy Create free account
hub / github.com/codeaashu/claude-code / classifyToolError

Function classifyToolError

src/services/tools/toolExecution.ts:150–171  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

148 * - Fallback: "Error" (better than a mangled 3-char identifier)
149 */
150export function classifyToolError(error: unknown): string {
151 if (
152 error instanceof TelemetrySafeError_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
153 ) {
154 return error.telemetryMessage.slice(0, 200)
155 }
156 if (error instanceof Error) {
157 // Node.js filesystem errors have a `code` property (ENOENT, EACCES, etc.)
158 // These are safe to log and much more useful than the constructor name.
159 const errnoCode = getErrnoCode(error)
160 if (typeof errnoCode === 'string') {
161 return `Error:${errnoCode}`
162 }
163 // ShellError, ImageSizeError, etc. have stable `.name` properties
164 // that survive minification (they're set in the constructor).
165 if (error.name && error.name !== 'Error' && error.name.length > 3) {
166 return error.name.slice(0, 60)
167 }
168 return 'Error'
169 }
170 return 'UnknownError'
171}
172
173/**
174 * Map a rule's origin to the documented OTel `source` vocabulary, matching

Callers 1

Calls 1

getErrnoCodeFunction · 0.85

Tested by

no test coverage detected