aboutsummaryrefslogtreecommitdiff
path: root/protocol/pktline/errors.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-10 13:28:59 +0800
committerGravatar Runxi Yu2026-03-10 13:28:59 +0800
commitaf08c84539f9353718604988ba27ae3c466860fc (patch)
tree0f1f2536f57af69b55ae06e78efbe26a7a0b3633 /protocol/pktline/errors.go
parentforgejo, github: Update issue templates (diff)
signatureNo signature
*: Move sideband64k and pktline to protocol/
Diffstat (limited to 'protocol/pktline/errors.go')
-rw-r--r--protocol/pktline/errors.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/protocol/pktline/errors.go b/protocol/pktline/errors.go
new file mode 100644
index 00000000..866ff467
--- /dev/null
+++ b/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
+}