API index and search · Build metadata
Source snapshot
packages/sql-client/src/errors.ts
1import type { RetryScope, StatementResult, TransactionState } from "./types.ts";23export interface RindleSqlErrorOptions {4 code: string;5 message: string;6 sqliteCode?: number;7 retryScope?: RetryScope;8 transactionState?: TransactionState;9 status?: number;10 requestId?: string;11 statementIndex?: number;12 partialResults?: StatementResult[];13 cause?: unknown;14}1516/** Stable error surfaced for both server envelopes and client-side contract refusals. */17export class RindleSqlError extends Error {18 readonly code: string;19 readonly sqliteCode: number | undefined;20 readonly retryScope: RetryScope;21 readonly transactionState: TransactionState | undefined;22 readonly status: number | undefined;23 readonly requestId: string | undefined;24 readonly statementIndex: number | undefined;25 readonly partialResults: StatementResult[] | undefined;2627 constructor(options: RindleSqlErrorOptions) {28 super(options.message, options.cause === undefined ? undefined : { cause: options.cause });29 this.name = "RindleSqlError";30 this.code = options.code;31 this.sqliteCode = options.sqliteCode;32 this.retryScope = options.retryScope ?? "never";33 this.transactionState = options.transactionState;34 this.status = options.status;35 this.requestId = options.requestId;36 this.statementIndex = options.statementIndex;37 this.partialResults = options.partialResults;38 }39}4041export function isRindleSqlError(error: unknown): error is RindleSqlError {42 return error instanceof RindleSqlError;43}4445export function valueUnsupported(message: string): RindleSqlError {46 return new RindleSqlError({ code: "VALUE_UNSUPPORTED", message, retryScope: "never" });47}4849export function protocolError(message: string, cause?: unknown): RindleSqlError {50 return new RindleSqlError({ code: "PROTOCOL_ERROR", message, retryScope: "never", cause });51}52