db/pg_error.ts

PostgreSQL error utilities.

Works with both pg and @electric-sql/pglite — both set .code on error objects using standard PostgreSQL error codes.

Declarations
#

view source

is_pg_unique_violation
#

db/pg_error.ts view source

(error: unknown): boolean

Check if an error is a PostgreSQL unique constraint violation (error code 23505).

error

the caught error

type unknown

returns

boolean

true if the error is a unique constraint violation

Imported by
#