-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy patherror.go
97 lines (90 loc) · 1.75 KB
/
error.go
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package irtt
// Common error codes.
const (
ShortWrite Code = -1 * (iota + 1)
InvalidDFString
FieldsLengthTooLarge
FieldsCapacityTooLarge
InvalidStampAtString
InvalidStampAtInt
InvalidAllowStampString
InvalidClockString
InvalidClockInt
BadMagic
NoHMAC
BadHMAC
UnexpectedHMAC
NonexclusiveMidpointTStamp
InconsistentClocks
DFNotSupported
InvalidFlagBitsSet
ShortParamBuffer
ParamOverflow
InvalidParamValue
ProtocolVersionMismatch
)
// Server error codes.
const (
NoMatchingInterfaces Code = -1 * (iota + 1*1024)
NoMatchingInterfacesUp
UnspecifiedWithSpecifiedAddresses
UnexpectedReplyFlag
NoSuitableAddressFound
InvalidConnToken
ShortInterval
LargeRequest
AddressMismatch
SyslogNotSupported
InvalidSyslogURI
)
// Client error codes.
const (
InvalidWinAvgWindow Code = -1 * (iota + 2*1024)
InvalidExpAvgAlpha
AllocateResultsPanic
UnexpectedOpenFlag
DFError
TTLError
ExpectedReplyFlag
ShortReply
StampAtMismatch
ClockMismatch
UnexpectedSequenceNumber
InvalidSleepFactor
InvalidWaitString
InvalidWaitFactor
InvalidWaitDuration
NoSuchAverager
NoSuchFiller
NoSuchTimer
NoSuchTimeSource
NoSuchWaiter
IntervalNonPositive
DurationNonPositive
ConnTokenZero
ServerClosed
OpenTimeout
InvalidServerRestriction
InvalidReceivedStatsInt
InvalidReceivedStatsString
OpenTimeoutTooShort
ServerFillTooLong
UnexpectedInitChannelClose
)
// Error is an IRTT error.
type Error struct {
*Event
}
// Errorf returns a new Error.
func Errorf(code Code, format string, detail ...interface{}) *Error {
return &Error{Eventf(code, nil, nil, format, detail...)}
}
func (e *Error) Error() string {
return e.Event.String()
}
func isErrorCode(code Code, err error) (matches bool) {
if e, ok := err.(*Error); ok {
matches = (e.Code == code)
}
return
}