-
Notifications
You must be signed in to change notification settings - Fork 1
/
error.go
53 lines (41 loc) · 984 Bytes
/
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
package easycall
import "strconv"
const (
ERROR_METHOD_NOT_FOUND = 1002
ERROR_SERVICE_NOT_FOUND = 1002
ERROR_INTERNAL_ERROR = 1001
ERROR_TIME_OUT = 1003
ERROR_MAX_SYSTEM_CODE = 2000 //the max system error code,less than 2000 is system error,more than 2000 is logic error
)
type LogicError struct {
ret int
msg string
}
func NewLogicError(ret int, msg string) *LogicError {
return &LogicError{ret, msg}
}
func (e *LogicError) Error() string {
return "Ret=" + strconv.Itoa(e.ret) + ",Msg=" + e.msg
}
func (e *LogicError) GetRet() int {
return e.ret
}
func (e *LogicError) GetMsg() string {
return e.msg
}
type SystemError struct {
ret int
msg string
}
func NewSystemError(ret int, msg string) *SystemError {
return &SystemError{ret, msg}
}
func (e *SystemError) Error() string {
return "Ret=" + strconv.Itoa(e.ret) + ",Msg=" + e.msg
}
func (e *SystemError) GetRet() int {
return e.ret
}
func (e *SystemError) GetMsg() string {
return e.msg
}