(err: unknown)
| 1 | // Map an arbitrary thrown value to a bounded, non-identifying category. |
| 2 | // NEVER returns the error message or stack — only a fixed-cardinality label. |
| 3 | export function errorClass(err: unknown): string { |
| 4 | const e = err as { name?: unknown; code?: unknown } | null; |
| 5 | const name = typeof e?.name === "string" ? e.name : ""; |
| 6 | const code = typeof e?.code === "string" ? e.code : ""; |
| 7 | const hay = `${name} ${code}`.toLowerCase(); |
| 8 | if (/abort|timeout|etimedout|deadline/.test(hay)) return "timeout"; |
| 9 | if (/network|fetch|econn|enotfound|socket|dns|epipe/.test(hay)) |
| 10 | return "network"; |
| 11 | if (/auth|unauthorized|forbidden|token|credential|401|403/.test(hay)) |
| 12 | return "auth"; |
| 13 | if (/zod|valid|schema|parse/.test(hay)) return "validation"; |
| 14 | return "unknown"; |
| 15 | } |
| 16 | |
| 17 | // `Adapter.platform` is a free-form string an adapter author sets, so a custom |
| 18 | // third-party adapter could put a tenant/project name there. Bound it to the |
no outgoing calls
no test coverage detected
searching dependent graphs…