/** * ClickHouse server error codes this package branches on. `@clickhouse/client` * carries them as STRING `code` values on `ClickHouseError`; the literals here * are the single source for every class set below. */ export declare const CLICKHOUSE_ERROR_CODES: { readonly UNKNOWN_TABLE: "60"; readonly UNKNOWN_DATABASE: "81"; readonly READONLY: "164"; readonly UNKNOWN_USER: "192"; readonly IP_ADDRESS_NOT_ALLOWED: "195"; readonly QUOTA_EXCEEDED: "201"; readonly TOO_MANY_SIMULTANEOUS_QUERIES: "202"; readonly SETTING_CONSTRAINT_VIOLATION: "452"; readonly ACCESS_DENIED: "497"; readonly AUTHENTICATION_FAILED: "516"; }; export type ClickHouseErrorCode = (typeof CLICKHOUSE_ERROR_CODES)[keyof typeof CLICKHOUSE_ERROR_CODES]; export type ClickHouseErrorClass = "absent" | "busy" | "denied" | "unreachable" | "indeterminate"; export interface ClickHouseErrorClassification { class: ClickHouseErrorClass; /** Server code (`"202"`) or Node error code (`"ECONNREFUSED"`) when one was found. */ code?: string; /** `busy` 202 only: the per-user cap (`user`) or the server-wide cap (`server`). */ scope?: "user" | "server"; /** Pre-masked via `maskSensitiveOutput` — safe for every sink without re-masking. */ message: string; } /** * Classifies any error raised on the ClickHouse path into the verdict the * caller needs — `absent` (table/database missing), `busy` (a concurrency or * quota cap tripped), `denied` (authentication / authorisation / constraint), * `unreachable` (the network or the client's own timeout/abort), or * `indeterminate`. * * Server codes are read from the `code` property (string per * `@clickhouse/client`; a numeric code is accepted defensively) or, when a * wrapper has flattened the error, from the `Code: NNN.` marker in the * message. A wrapper carrying no code of its own but a `cause` is classified * by that cause; the wrapper's message is kept. Pre-masked producer: * `message` has been through `maskSensitiveOutput` — sinks must not re-mask. */ export declare function classifyClickHouseError(err: unknown): ClickHouseErrorClassification; /** `denied 497` / `unreachable ECONNREFUSED` / `indeterminate` — for error messages and log context. */ export declare function describeClickHouseErrorClass(classification: ClickHouseErrorClassification): string;