mirror of https://github.com/jackc/pgx.git
Extract more error information
parent
92cbc6566d
commit
a5f082fa03
14
conn.go
14
conn.go
|
@ -676,6 +676,20 @@ func (c *Conn) rxErrorResponse(r *msgReader) (err PgError) {
|
|||
err.Code = r.readCString()
|
||||
case 'M':
|
||||
err.Message = r.readCString()
|
||||
case 'D':
|
||||
err.Detail = r.readCString()
|
||||
case 'H':
|
||||
err.Hint = r.readCString()
|
||||
case 's':
|
||||
err.SchemaName = r.readCString()
|
||||
case 't':
|
||||
err.TableName = r.readCString()
|
||||
case 'c':
|
||||
err.ColumnName = r.readCString()
|
||||
case 'd':
|
||||
err.DataTypeName = r.readCString()
|
||||
case 'n':
|
||||
err.ConstraintName = r.readCString()
|
||||
case 0: // End of error message
|
||||
if err.Severity == "FATAL" {
|
||||
c.die(err)
|
||||
|
|
16
messages.go
16
messages.go
|
@ -60,10 +60,20 @@ type FieldDescription struct {
|
|||
FormatCode int16
|
||||
}
|
||||
|
||||
// PgError represents an error reported by the PostgreSQL server. See
|
||||
// http://www.postgresql.org/docs/9.3/static/protocol-error-fields.html for
|
||||
// detailed field description.
|
||||
type PgError struct {
|
||||
Severity string
|
||||
Code string
|
||||
Message string
|
||||
Severity string
|
||||
Code string
|
||||
Message string
|
||||
Detail string
|
||||
Hint string
|
||||
SchemaName string
|
||||
TableName string
|
||||
ColumnName string
|
||||
DataTypeName string
|
||||
ConstraintName string
|
||||
}
|
||||
|
||||
func (self PgError) Error() string {
|
||||
|
|
Loading…
Reference in New Issue