A tiny Go package for checking errors returned by pgx, a Go driver for PostgreSQL.
go get github.com/orsinium-labs/pgerrsif pgerrs.Is(err, pgerrs.CheckViolation) {
println("violates a CHECK")
}
if pgerrs.ViolatesForeignKeyConstraint(err, "users", "address_id") {
println("cannot add user, invalid address_id")
}
if pgerrs.ViolatesUniqueConstraint(err, "users", "email") {
println("user with the given email already exists")
}
if pgerrs.ViolatesConstraint(err, "connections_from_to_key") {
println("there can be only one connection with the given `from` and `to`")
}