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

Function classifyError

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

Source from the content-addressed store, hash-verified

60const clickhouseSyntaxErrorCodes = new Set([36, 60, 62, 242])
61
62const classifyError = (
63 cause: unknown,
64 message: string,
65 operation: string,
66 fallback: "connection" | "unknown" = "unknown"
67) => {
68 const props = { cause, message, operation }
69 const code = clickhouseCodeFromCause(cause)
70 if (code !== undefined) {
71 if (code === 516) {
72 return new AuthenticationError(props)
73 }
74 if (code === 497) {
75 return new AuthorizationError(props)
76 }
77 if (clickhouseSyntaxErrorCodes.has(code)) {
78 return new SqlSyntaxError(props)
79 }
80 if (code === 159 || code === 469) {
81 return new StatementTimeoutError(props)
82 }
83 }
84 return fallback === "connection" ? new ConnectionError(props) : new UnknownError(props)
85}
86
87const killQuery = (client: Clickhouse.ClickHouseClient, queryId: string) =>
88 Effect.promise(() =>

Callers 5

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

Calls 2

clickhouseCodeFromCauseFunction · 0.85
hasMethod · 0.65

Tested by

no test coverage detected