-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherrors.go
More file actions
73 lines (58 loc) · 1.77 KB
/
errors.go
File metadata and controls
73 lines (58 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// SPDX-FileCopyrightText: 2025 Comcast Cable Communications Management, LLC
// SPDX-License-Identifier: Apache-2.0
package wrpssp
import (
"errors"
"fmt"
"io"
)
var (
// ErrInvalidInput is returned when the input to a function is invalid.
ErrInvalidInput = errors.New("invalid input")
// ErrClosed is returned when an operation is attempted on a closed stream.
ErrClosed = errors.New("closed")
// ErrPacketGapExceeded is returned when a packet is received that is too
// far ahead of the current packet.
ErrPacketGapExceeded = errors.New("packet gap exceeded")
// ErrNotAvailable is returned to indicate that the requested information is
// not available.
ErrNotAvailable = errors.New("information not available")
)
type unexpectedEOF struct {
message string
messageErr error
}
func (e *unexpectedEOF) Error() string {
return fmt.Sprintf("%s: %s", io.ErrUnexpectedEOF.Error(), e.message)
}
func (e *unexpectedEOF) Is(target error) bool {
return errors.Is(target, io.ErrUnexpectedEOF)
}
func (e *unexpectedEOF) Unwrap() []error {
return []error{
io.ErrUnexpectedEOF,
e.messageErr,
}
}
// newUnexpectedEOF creates a new unexpectedEOF error with the given message.
func newUnexpectedEOF(message string) *unexpectedEOF {
return &unexpectedEOF{
message: message,
messageErr: errors.New(message),
}
}
type packetGapExceeded struct {
current int64
received int64
maxGap int
}
func (e *packetGapExceeded) Error() string {
return fmt.Sprintf("%s: received packet %d while at %d (gap %d > max %d)",
ErrPacketGapExceeded.Error(), e.received, e.current, e.received-e.current, e.maxGap)
}
func (e *packetGapExceeded) Is(target error) bool {
return errors.Is(target, ErrPacketGapExceeded)
}
func (e *packetGapExceeded) Unwrap() error {
return ErrPacketGapExceeded
}