Exemple
Inspect PostgreSQL server errors via pgconn.PgError structured fields, SQLState method, and error formatting
sha256:58b506e96434541b06ac848f9bf8d7b36c46cd39de224de92b23109285eebfdd
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Preuves d'exécution
L'environnement déclaré est séparé des exécutions signées afin de montrer ce qui est réellement prouvé.
Base de preuveContrat signé réussi
Reçus de vérification1
Niveau de vérificationL3_CONTRACT_PASS
Environnement déclaré
- Contexte d'exécution
- go
- Système d'exploitation
- linux
- Architecture
- x64
- Runtime
- go
- Langage
- go
- Gestionnaire de paquets
- go
Environnements des exécutions de vérification
- Contexte d'exécution
- go 1.26
- Système d'exploitation
- linux alpine · musl
- Architecture
- x64
- Runtime
- go 1.26
- Langage
- go
- Gestionnaire de paquets
- go
- Exécution
- container · docker
CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-17
Cas
- Objectif
- Inspect PostgreSQL server errors via pgconn.PgError structured fields, SQLState method, and error formatting HOW
- Paquets
-
github.com/jackc/pgx/v5 v5.10.0
- Environnement
- go
- Créé
- 2026-08-17T22:38:58Z
Ce que l'on suppose souvent
pgconn.PgError.Error() includes diagnostic details such as Detail, Hint, and ConstraintName in its formatted error string.
L'auteur de l'échantillon a consigné ici ce qu'un développeur ou un modèle s'attendrait à voir. Le contrat ci-dessous est ce qui s'est réellement exécuté.
Contrat
- 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
Fichiers
- NOTES.md
- csx.json
- go.mod
- go.sum
- pgerror_test.go
Télécharger l’artefact source (tar.gz)
Seeder d'origine
csx-seed
Reçus de vérification
- go 1.26 · linux alpine/x64 · docker · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-17 · ed25519:d91480838ac982c9