Source File
error_response.go
Belonging Package
github.com/jackc/pgproto3/v2
package pgproto3
import (
)
type ErrorResponse struct {
Severity string
Code string
Message string
Detail string
Hint string
Position int32
InternalPosition int32
InternalQuery string
Where string
SchemaName string
TableName string
ColumnName string
DataTypeName string
ConstraintName string
File string
Line int32
Routine string
UnknownFields map[byte]string
}
func (*ErrorResponse) () {}
func ( *ErrorResponse) ( []byte) error {
* = ErrorResponse{}
:= bytes.NewBuffer()
for {
, := .ReadByte()
if != nil {
return
}
if == 0 {
break
}
, := .ReadBytes(0)
if != nil {
return
}
:= string([:len()-1])
switch {
case 'S':
.Severity =
case 'C':
.Code =
case 'M':
.Message =
case 'D':
.Detail =
case 'H':
.Hint =
case 'P':
:=
, := strconv.ParseInt(, 10, 32)
.Position = int32()
case 'p':
:=
, := strconv.ParseInt(, 10, 32)
.InternalPosition = int32()
case 'q':
.InternalQuery =
case 'W':
.Where =
case 's':
.SchemaName =
case 't':
.TableName =
case 'c':
.ColumnName =
case 'd':
.DataTypeName =
case 'n':
.ConstraintName =
case 'F':
.File =
case 'L':
:=
, := strconv.ParseInt(, 10, 32)
.Line = int32()
case 'R':
.Routine =
default:
if .UnknownFields == nil {
.UnknownFields = make(map[byte]string)
}
.UnknownFields[] =
}
}
return nil
}
func ( *ErrorResponse) ( []byte) []byte {
return append(, .marshalBinary('E')...)
}
func ( *ErrorResponse) ( byte) []byte {
var BigEndianBuf
:= &bytes.Buffer{}
.WriteByte()
.Write(.Uint32(0))
if .Severity != "" {
.WriteByte('S')
.WriteString(.Severity)
.WriteByte(0)
}
if .Code != "" {
.WriteByte('C')
.WriteString(.Code)
.WriteByte(0)
}
if .Message != "" {
.WriteByte('M')
.WriteString(.Message)
.WriteByte(0)
}
if .Detail != "" {
.WriteByte('D')
.WriteString(.Detail)
.WriteByte(0)
}
if .Hint != "" {
.WriteByte('H')
.WriteString(.Hint)
.WriteByte(0)
}
if .Position != 0 {
.WriteByte('P')
.WriteString(strconv.Itoa(int(.Position)))
.WriteByte(0)
}
if .InternalPosition != 0 {
.WriteByte('p')
.WriteString(strconv.Itoa(int(.InternalPosition)))
.WriteByte(0)
}
if .InternalQuery != "" {
.WriteByte('q')
.WriteString(.InternalQuery)
.WriteByte(0)
}
if .Where != "" {
.WriteByte('W')
.WriteString(.Where)
.WriteByte(0)
}
if .SchemaName != "" {
.WriteByte('s')
.WriteString(.SchemaName)
.WriteByte(0)
}
if .TableName != "" {
.WriteByte('t')
.WriteString(.TableName)
.WriteByte(0)
}
if .ColumnName != "" {
.WriteByte('c')
.WriteString(.ColumnName)
.WriteByte(0)
}
if .DataTypeName != "" {
.WriteByte('d')
.WriteString(.DataTypeName)
.WriteByte(0)
}
if .ConstraintName != "" {
.WriteByte('n')
.WriteString(.ConstraintName)
.WriteByte(0)
}
if .File != "" {
.WriteByte('F')
.WriteString(.File)
.WriteByte(0)
}
if .Line != 0 {
.WriteByte('L')
.WriteString(strconv.Itoa(int(.Line)))
.WriteByte(0)
}
if .Routine != "" {
.WriteByte('R')
.WriteString(.Routine)
.WriteByte(0)
}
for , := range .UnknownFields {
.WriteByte()
.WriteByte(0)
.WriteString()
.WriteByte(0)
}
.WriteByte(0)
binary.BigEndian.PutUint32(.Bytes()[1:5], uint32(.Len()-1))
return .Bytes()
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |