Skip to main content

@rtorcato/supabase-common / PG_ERROR_CODES

Variable: PG_ERROR_CODES

const PG_ERROR_CODES: object

Defined in: errors.ts:6

The error codes a Supabase dev checks for by hand over and over: Postgres SQLSTATEs surfaced through PostgREST, plus PostgREST's own PGRSTxxx codes. Named here so callers stop sprinkling magic strings like '23505'.

Type Declaration

uniqueViolation

readonly uniqueViolation: "23505" = '23505'

foreignKeyViolation

readonly foreignKeyViolation: "23503" = '23503'

notNullViolation

readonly notNullViolation: "23502" = '23502'

checkViolation

readonly checkViolation: "23514" = '23514'

exclusionViolation

readonly exclusionViolation: "23P01" = '23P01'

insufficientPrivilege

readonly insufficientPrivilege: "42501" = '42501'

RLS / permission denied (insufficient_privilege).

serializationFailure

readonly serializationFailure: "40001" = '40001'

Serialization failure — safe to retry.

deadlockDetected

readonly deadlockDetected: "40P01" = '40P01'

Deadlock — safe to retry.

queryCanceled

readonly queryCanceled: "57014" = '57014'

Statement timeout (query_canceled).

noRows

readonly noRows: "PGRST116" = 'PGRST116'

PostgREST: query for a single row matched zero rows.

jwtExpired

readonly jwtExpired: "PGRST301" = 'PGRST301'

PostgREST: JWT expired.