import type { SqlQuery } from './types.js'; /** * Normalized category for a database error. `kind` is what application code * branches on (`error.kind === 'unique_violation'`) instead of string-matching * driver messages. Names are SQLSTATE-aligned so that when a postgres adapter * lands the mapping is a direct lookup rather than a second vocabulary. * * `'unknown'` is the explicit "we couldn't classify this" signal — users who * see it in production should file a bug; the mapper is library-maintained, * not user-overridable. */ export type SqlfuErrorKind = 'syntax' | 'missing_table' | 'missing_column' | 'unique_violation' | 'not_null_violation' | 'foreign_key_violation' | 'check_violation' | 'transient' | 'unknown'; export interface SqlfuErrorContext { query: SqlQuery; system: string; } /** * Every sqlfu adapter throws this. `kind` is the normalized discriminator; * `cause` preserves the driver's original error byte-identical so users who * need adapter-specific fields (`rawCode`, `errcode`, `resultCode`, etc.) * still have a path. `query` and `system` are on the error itself so a * plain `catch` block can tag a query name or system without restructuring * around the hook API. * * `message` and `stack` come from the driver error verbatim — the user's * call-site frame is the first useful frame, and sqlfu internals would be * noise in production stacks. */ export declare class SqlfuError extends Error { kind: SqlfuErrorKind; query: SqlQuery; system: string; cause: unknown; constructor(params: { kind: SqlfuErrorKind; query: SqlQuery; system: string; cause: unknown; }); } /** Normalize a sqlite driver error onto `SqlfuError`. Idempotent. */ export declare function mapSqliteDriverError(error: unknown, context: SqlfuErrorContext): SqlfuError;