-
Notifications
You must be signed in to change notification settings - Fork 2
/
errors.go
57 lines (44 loc) · 1.05 KB
/
errors.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
/*
FlyRPC provide a flexiable way to communicate between Server and Client.
It support JSON, Msgpack, Protobuf serializer.
It support Call/Response or Send/Receive pattern.
*/
package flyrpc
import "errors"
const (
// Common error
ErrTimeOut string = "TIMEOUT"
// 10000 - 20000 client error
ErrNotFound string = "NOT_FOUND"
ErrUnknownSubType string = "UNKNOWN_SUB_TYPE"
ErrBuffTooLong string = "BUFF_TOO_LONG"
// 20000 + server error
ErrNoWriter string = "NO_WRITER"
ErrWriterClosed string = "WRITER_CLOSED"
ErrHandlerPanic string = "HANDLER_PANIC"
// 25000 + serializer error
ErrNotProtoMessage string = "NOT_PROTOBUF_MESSAGE"
)
type ReplyError struct {
code string
cause error
pkt *Packet
}
func (e *ReplyError) Error() string {
return e.code
}
func newReplyError(code string, pkt *Packet) *ReplyError {
return &ReplyError{
code: code,
pkt: pkt,
}
}
func newError(code string) error {
return errors.New(code)
}
func newFlyError(code string, cause error) error {
return &ReplyError{
code: code,
cause: cause,
}
}