mirror of
https://github.com/jackc/pgx.git
synced 2025-07-10 20:48:09 +00:00
Updated Error Handling (markdown)
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user