( error: unknown, )
| 236 | | 'unknown' |
| 237 | |
| 238 | export function classifyPluginCommandError( |
| 239 | error: unknown, |
| 240 | ): PluginCommandErrorCategory { |
| 241 | const msg = String((error as { message?: unknown })?.message ?? error) |
| 242 | if ( |
| 243 | /ENOTFOUND|ECONNREFUSED|EAI_AGAIN|ETIMEDOUT|ECONNRESET|network|Could not resolve|Connection refused|timed out/i.test( |
| 244 | msg, |
| 245 | ) |
| 246 | ) { |
| 247 | return 'network' |
| 248 | } |
| 249 | if (/\b404\b|not found|does not exist|no such plugin/i.test(msg)) { |
| 250 | return 'not-found' |
| 251 | } |
| 252 | if (/\b40[13]\b|EACCES|EPERM|permission denied|unauthorized/i.test(msg)) { |
| 253 | return 'permission' |
| 254 | } |
| 255 | if (/invalid|malformed|schema|validation|parse error/i.test(msg)) { |
| 256 | return 'validation' |
| 257 | } |
| 258 | return 'unknown' |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * Emit tengu_plugin_load_failed once per error surfaced by session-start |
no outgoing calls
no test coverage detected