modulepackage
0.0.0-20210217003926-aac2ed30d5c7
Repository: https://github.com/shanna/pgstatus-go.git
Documentation: pkg.go.dev
# README
pgstatus-go
Postgres error to gRPC status.
Supports any error
implementing a SQLState() string
method that:
- Returns a postgres error code.
- Isn't already a gRPC
*status.Status
pointer. - Doesn't implement a
GRPCStatus() *grpc.Status
.
Drivers
github.com/jackc/pgx
Supported as of github.com/jackc/pgx/v4
. YMMV if you are using older version that don't use
github.com/jackc/pgconn
as I don't know the history of the SQLState() string
interface
in the driver.
github.com/lib/pq
Unsupported.
The pq package provides no usable interface. Casting to a *pq.Error and providing a
SQLState() string
is currently an exercise left to the reader.
github.com/go-pg/pg
Unsupported.
License
MIT
# Functions
Code converts a database error into a gRPC codes.Code.
ConditionName for SQLStatus() interface error code.
Convert is a convenience function which removes the need to handle the boolean return value from FromError.
FromError returns a gRPC status.Status representing an err if it was produced from status package, has a method `GRPCStatus() *status.Status` or has a method SQLState interface returning a postgres error code.
# Interfaces
SQLState error code interface.