lib / pq

Pure Go Postgres driver for database/sql
https://pkg.go.dev/github.com/lib/pq
MIT License
9.11k stars 911 forks source link

Include error code in error string #895

Open dcormier opened 5 years ago

dcormier commented 5 years ago

I've run into a number of times where I encounter a *pq.Error and realize I need some special handling for it. But I need to know the Postgres error code so I can check to make sure I'm handling the right error.

Currently, I have to look at the error string, try to figure out what error code it is (having neither the error code nor the condition name listed here), then add the needed special handling for the specific error code.

It would be really nice if the error string ((*pq.Error).Error()) just included the error code to ease special handling needed for that error.