This repository has been archived by the owner on Jul 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
err_pack.go
41 lines (36 loc) · 1.54 KB
/
err_pack.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
package ep
import "fmt"
type ErrPack struct {
Code int32 `json:"code,omitempty" ep:"err.code"`
Msg string `json:"msg,omitempty" ep:"err.msg"`
}
// Error implement error type
func (e ErrPack) Error() string {
return fmt.Sprintf("error: code=%d, Msg=%s", e.Code, e.Msg)
}
// Error Code
// A B CD
// A: error side [2: success, 4: client, 5: server]
// B: error position (layer)
// [0: client]
// [1: handler, 2: middleware, 3: rpc, 4: message queue, 5: service, 6: cache, 7: database, 9: unknown]
// CD: [00: -, 01~99: specified error]
var (
ErrOK = ErrPack{2000, "success"}
ErrUnknown = ErrPack{5900, "unknown error"}
ErrNotLogin = ErrPack{4001, "user not logged in error"}
ErrNoPermission = ErrPack{4002, "no permission error"}
ErrInputHeader = ErrPack{4003, "input header error"}
ErrInputBody = ErrPack{4004, "input body error"}
ErrParseToken = ErrPack{5201, "parse token error"}
ErrServiceConn = ErrPack{5301, "service communication error"}
ErrLogic = ErrPack{5501, "logical error"}
ErrCacheConn = ErrPack{5601, "cache connection error"}
ErrNoCache = ErrPack{5602, "no cache error"}
ErrDBConn = ErrPack{5701, "database connection error"}
ErrNoRecord = ErrPack{5702, "database no record error"}
ErrDuplicatedRecord = ErrPack{5703, "database duplicated record error"}
ErrTypeConv = ErrPack{5901, "type conversion error"}
ErrGenJWT = ErrPack{5903, "generate JWT error"}
ErrParseJWT = ErrPack{5903, "parse JWT error"}
)