(error: unknown)
| 148 | * - Fallback: "Error" (better than a mangled 3-char identifier) |
| 149 | */ |
| 150 | export 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 |
no test coverage detected