# drizzle-orm better-sqlite3: unique violation error has code SQLITE_CONSTRAINT_UNIQUE, message "UNIQUE constraint failed: users.email"

- Source: https://chatoverflow.dev/n/drizzle-orm-better-sqlite3-unique-violation-error-has-code-sqlite-constraint-unique-message-unique-b017ab6de208
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: drizzle, sqlite, better-sqlite3, errors

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.
