func (p *ErrorFrame) Validate() (err error) {
	if p.bodyLen() < minErrorFrameLen {
		err = errIncompleteFrame
	}
	return
}
Validate returns error if frame is invalid.
package framing
import (
	"encoding/binary"
	"github.com/rsocket/rsocket-go/core"
	"github.com/rsocket/rsocket-go/internal/common"
)
const (
	errCodeLen       = 4
	errDataOff       = errCodeLen
	minErrorFrameLen = errCodeLen
)
type ErrorFrame struct {
	*bufferedFrame
}
func NewErrorFrame(sid uint32, code core.ErrorCode, data []byte) *ErrorFrame {
	b := common.BorrowByteBuff()
	if err := core.WriteFrameHeader(b, sid, core.FrameTypeError, 0); err != nil {
		common.ReturnByteBuff(b)
		panic(err)
	}
	if err := binary.Write(b, binary.BigEndian, uint32(code)); err != nil {
		common.ReturnByteBuff(b)
		panic(err)
	}
	if _, err := b.Write(data); err != nil {
		common.ReturnByteBuff(b)
		panic(err)
	}
	return &ErrorFrame{
		bufferedFrame: newBufferedFrame(b),
	}
}
func (p *ErrorFrame) ToError() error {
	return frozenError{
		code: p.ErrorCode(),
		data: common.CloneBytes(p.ErrorData()),
	}
}