Files
zeekay 765c3d0aa1 hanzo-ds/native: de-branded native protocol lib (fork of clickhouse ch-go v0.71.0)
Module path, package names, and identifiers de-branded to native/proto/compress/
pool/tracing. Server wire-protocol strings preserved. Vendored codec surface used
by hanzo-ds/go (proto + compress).
2026-07-10 13:10:07 -07:00

60 lines
1006 B
Go

package proto
import "github.com/go-faster/errors"
// Exception is server-side error.
type Exception struct {
Code Error
Name string
Message string
Stack string
Nested bool
}
// DecodeAware decodes exception.
func (e *Exception) DecodeAware(r *Reader, _ int) error {
code, err := r.Int32()
if err != nil {
return errors.Wrap(err, "code")
}
e.Code = Error(code)
{
s, err := r.Str()
if err != nil {
return errors.Wrap(err, "name")
}
e.Name = s
}
{
s, err := r.Str()
if err != nil {
return errors.Wrap(err, "message")
}
e.Message = s
}
{
s, err := r.Str()
if err != nil {
return errors.Wrap(err, "stack trace")
}
e.Stack = s
}
nested, err := r.Bool()
if err != nil {
return errors.Wrap(err, "nested")
}
e.Nested = nested
return nil
}
// EncodeAware encodes exception.
func (e *Exception) EncodeAware(b *Buffer, _ int) {
b.PutInt32(int32(e.Code))
b.PutString(e.Name)
b.PutString(e.Message)
b.PutString(e.Stack)
b.PutBool(e.Nested)
}