(raw: string)
| 15 | }; |
| 16 | |
| 17 | export function classifyError(raw: string): ErrKind { |
| 18 | const s = raw.toLowerCase(); |
| 19 | // Auth first — a 401 with "network" in the text should still be auth. |
| 20 | if (/\b401\b|api[_ -]?key|unauthorized|incorrect api key|forbidden/.test(s)) return "auth"; |
| 21 | // libuv connect family + generic network/timeout wording. |
| 22 | if (/fetch failed|econn|enotfound|etimedout|eai_again|ehostunreach|timed out|timeout|network|socket hang up|aborted/.test(s)) { |
| 23 | return "network"; |
| 24 | } |
| 25 | if (/\b429\b|\brate[ _-]?limit\b|too many requests/.test(s)) return "ratelimit"; |
| 26 | return "generic"; |
| 27 | } |
no outgoing calls
no test coverage detected