MCPcopy
hub / github.com/CopilotKit/CopilotKit / errorClass

Function errorClass

packages/bot/src/telemetry/sanitize-error.ts:3–15  ·  view source on GitHub ↗
(err: unknown)

Source from the content-addressed store, hash-verified

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.
3export 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

Callers 3

startFunction · 0.85
runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…