Updated Error Handling (markdown)

Jack Christensen 2023-05-13 09:54:56 -05:00
parent a7e0765054
commit f63ffedac7

@ -5,6 +5,11 @@ pgx uses Go 1.13+ style error wrapping. That means that `errors.Is()` and `error
If an error is returned from PostgreSQL then underlying error type will be a [*pgconn.PgError](https://pkg.go.dev/github.com/jackc/pgconn?tab=doc#PgError).
```go
// Be sure the correct package is imported, this will not work if the old, standalone pgconn repo is imported instead.
import "github.com/jackc/pgx/v5/pgconn"
// ...
err = conn.QueryRow(context.Background(), "select 1 +").Scan(&greeting)
if err != nil {
var pgErr *pgconn.PgError