MCPcopy Create free account
hub / github.com/Noumena-Network/code / classifyToolError

Function classifyToolError

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

Source from the content-addressed store, hash-verified

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