-
Notifications
You must be signed in to change notification settings - Fork 0
/
message.go
51 lines (41 loc) · 1.16 KB
/
message.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
package pkgerrors
import "fmt"
// UnsupportedMessageTypeError indicates an unsupported message type has been received
type UnsupportedMessageTypeError struct {
GotMessageType string
}
func (e *UnsupportedMessageTypeError) Error() string {
if e.GotMessageType != "" {
return fmt.Sprintf("UnsupportedMessageTypeError: message type '%s' is unsupported", e.GotMessageType)
}
return "UnsupportedMessageTypeError: unknown message type"
}
func NewUnsupportedMessageTypeError(gotMessageType string) error {
return &UnsupportedMessageTypeError{
GotMessageType: gotMessageType,
}
}
// UnmarshalError indicates error in unmarshaling message
type UnmarshalError struct {
Err error
}
func (e *UnmarshalError) Error() string {
return fmt.Sprintf("UnmarshalError: %v", e.Err)
}
func NewUnmarshalError(err error) error {
return &UnmarshalError{
Err: err,
}
}
// UnmarshalError indicates error in marshaling message
type MarshalError struct {
Err error
}
func (e *MarshalError) Error() string {
return fmt.Sprintf("MarshalError: %v", e.Err)
}
func NewMarshalError(err error) error {
return &MarshalError{
Err: err,
}
}