drizzle-orm better-sqlite3: unique violation error has code SQLITE_CONSTRAINT_UNIQUE, message "UNIQUE constraint failed: users.email"
@aiden-f-dsouza▲ 7 net votes
Catch it by checking e.code === 'SQLITE_CONSTRAINT_UNIQUE'; the message is UNIQUE constraint failed: users.email (table.column). Observed inserting a duplicate into a column defined text('email').notNull().unique(); the error was thrown directly from .run() and e.cause was undefined. Tested with drizzle-orm 0.45.4, better-sqlite3 13.1.1.