Beispiel
Inspect PostgreSQL server errors via pgconn.PgError structured fields, SQLState method, and error formatting
sha256:58b506e96434541b06ac848f9bf8d7b36c46cd39de224de92b23109285eebfdd
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Ausführungsbelege
Deklarierte Umgebung und signierte Prüfläufe werden getrennt dargestellt.
BeleggrundlageSignierter Vertrag bestanden
Verifizierungsbelege1
VerifizierungsstufeL3_CONTRACT_PASS
Deklarierte Umgebung
- Ausführungskontext
- go
- Betriebssystem
- linux
- Architektur
- x64
- Runtime
- go
- Sprache
- go
- Paketmanager
- go
Umgebungen der Verifizierungsläufe
- Ausführungskontext
- go 1.26
- Betriebssystem
- linux alpine · musl
- Architektur
- x64
- Runtime
- go 1.26
- Sprache
- go
- Paketmanager
- go
- Ausführung
- container · docker
CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-17
Fall
- Ziel
- Inspect PostgreSQL server errors via pgconn.PgError structured fields, SQLState method, and error formatting HOW
- Pakete
-
github.com/jackc/pgx/v5 v5.10.0
- Umgebung
- go
- Erstellt
- 2026-08-17T22:38:58Z
Häufige Annahme
pgconn.PgError.Error() includes diagnostic details such as Detail, Hint, and ConstraintName in its formatted error string.
So hat der Autor des Samples festgehalten, was eine Entwicklerin oder ein Modell hier erwarten würde. Der Vertrag darunter ist das, was tatsächlich lief.
Contract
- pgconn.PgError.Error() formats only the severity, message, and SQLSTATE code, leaving Detail, Hint, and constraint metadata accessible exclusively through struct fields
- pgconn.PgError.SQLState() returns the 5-character SQL standard error code matching the Code field
- errors.As successfully extracts *pgconn.PgError when wrapped inside standard error chains
- pgconn.ErrorResponseToPgError maps wire protocol pgproto3.ErrorResponse fields into a *pgconn.PgError struct
Dateien
- NOTES.md
- csx.json
- go.mod
- go.sum
- pgerror_test.go
Quellartefakt herunterladen (tar.gz)
Ursprungs-Seeder
csx-seed
Verifizierungsbelege
- go 1.26 · linux alpine/x64 · docker · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-17 · ed25519:d91480838ac982c9