MCPcopy Create free account
hub / github.com/Effect-TS/effect / classifyError

Function classifyError

packages/sql/clickhouse/src/ClickhouseClient.ts:61–84  ·  view source on GitHub ↗
(
  cause: unknown,
  message: string,
  operation: string,
  fallback: "connection" | "unknown" = "unknown"
)

Source from the content-addressed store, hash-verified

59const clickhouseSyntaxErrorCodes = new Set([36, 60, 62, 242])
60
61const classifyError = (
62 cause: unknown,
63 message: string,
64 operation: string,
65 fallback: "connection" | "unknown" = "unknown"
66) => {
67 const props = { cause, message, operation }
68 const code = clickhouseCodeFromCause(cause)
69 if (code !== undefined) {
70 if (code === 516) {
71 return new AuthenticationError(props)
72 }
73 if (code === 497) {
74 return new AuthorizationError(props)
75 }
76 if (clickhouseSyntaxErrorCodes.has(code)) {
77 return new SqlSyntaxError(props)
78 }
79 if (code === 159 || code === 469) {
80 return new StatementTimeoutError(props)
81 }
82 }
83 return fallback === "connection" ? new ConnectionError(props) : new UnknownError(props)
84}
85
86/**
87 * Unique runtime identifier used to tag `ClickhouseClient` values.

Callers 5

makeFunction · 0.70
runRawMethod · 0.70
runMethod · 0.70
executeStreamMethod · 0.70
insertQueryFunction · 0.70

Calls 2

clickhouseCodeFromCauseFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected