diff options
| author | 2026-03-25 16:22:03 +0000 | |
|---|---|---|
| committer | 2026-03-25 16:22:03 +0000 | |
| commit | 311edcd50f3a84f4b860bde3cb887451d74eaa11 (patch) | |
| tree | be7aa5e9a51e636358f33b1c90637b5024b70dc3 /network/protocol/pktline/errors.go | |
| parent | README: Split off contrib, benchmarks, remove history for now I guess, etc. (diff) | |
| signature | No signature | |
network/protocol: Rename from protocol v0.1.110
Diffstat (limited to 'network/protocol/pktline/errors.go')
| -rw-r--r-- | network/protocol/pktline/errors.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/network/protocol/pktline/errors.go b/network/protocol/pktline/errors.go new file mode 100644 index 00000000..866ff467 --- /dev/null +++ b/network/protocol/pktline/errors.go @@ -0,0 +1,31 @@ +package pktline + +import "errors" + +var ( + // ErrInvalidLength indicates a malformed 4-byte hexadecimal length header. + ErrInvalidLength = errors.New("pktline: invalid length header") + // ErrTooLarge indicates a payload exceeds configured packet data limits. + ErrTooLarge = errors.New("pktline: payload too large") +) + +// ProtocolError reports invalid pkt-line framing. +// +// It is returned for protocol violations such as invalid control values +// (for example 0003) or non-hex length headers. +type ProtocolError struct { + Header [4]byte + Reason string +} + +func (e *ProtocolError) Error() string { + if e == nil { + return "<nil>" + } + + if e.Reason == "" { + return "pktline: protocol error" + } + + return "pktline: protocol error: " + e.Reason +} |
