/** * True when the failure is SQLite's UNIQUE constraint. Drizzle wraps driver * errors, so the libsql error sits at some depth of the `cause` chain. */ export function isUniqueViolation(error: unknown): boolean { let current: unknown = error; while (current instanceof Error) { if ('code' in current && current.code === 'SQLITE_CONSTRAINT_UNIQUE') return true; current = current.cause; } return false; }