pgerr

package
v2.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package pgerr provides PostgreSQL error inspection helpers built on pgconn.PgError. SQLSTATE code constants are re-exported from github.com/jackc/pgerrcode — import that package directly if you need the full table of codes or class-membership helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsErrorNoRows

func IsErrorNoRows(err error) bool

IsErrorNoRows reports whether err is or wraps pgx.ErrNoRows or sql.ErrNoRows.

func IsFatal

func IsFatal(err error) bool

IsFatal reports whether err is a Postgres error that should be treated as fatal for retry/alerting purposes. SQLSTATE classes 00 (success), 01 (warning), 02 (no data), and 23 (integrity constraint violation) are non-fatal; every other class is fatal. Non-PgError errors return false (no opinion).

func IsUniqueViolation

func IsUniqueViolation(err error) (string, bool)

IsUniqueViolation reports whether err is a Postgres unique constraint violation (SQLSTATE 23505). When true, the returned string is the constraint name reported by the server (empty if the driver did not surface it).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL