-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconst.go
61 lines (53 loc) · 3.27 KB
/
const.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
package cerror
import (
"context"
"net/http"
)
// system,start from 1000
var (
ErrServerClosing = MakeCError(1000, http.StatusServiceUnavailable, "server is closing")
ErrClientClosing = MakeCError(1001, http.StatusBadRequest, "using closed client")
ErrTarget = MakeCError(1002, http.StatusBadRequest, "wrong server,check the server group and name")
ErrNoapi = MakeCError(1003, http.StatusNotImplemented, "api not implement")
ErrPanic = MakeCError(1004, http.StatusServiceUnavailable, "panic")
ErrNoserver = MakeCError(1005, http.StatusServiceUnavailable, "no servers")
ErrNoSpecificserver = MakeCError(1006, http.StatusServiceUnavailable, "no specific server")
ErrDiscoverStopped = MakeCError(1007, http.StatusBadRequest, "discover stopped")
ErrClosed = MakeCError(1008, http.StatusInternalServerError, "connection closed")
ErrReqmsgLen = MakeCError(1009, http.StatusBadRequest, "req msg too large")
ErrRespmsgLen = MakeCError(1010, http.StatusInternalServerError, "resp msg too large")
ErrCors = MakeCError(2001, http.StatusForbidden, "Cors forbidden")
)
var (
ErrDataConflict = MakeCError(9001, http.StatusInternalServerError, "data conflict")
ErrDataBroken = MakeCError(9002, http.StatusInternalServerError, "data broken")
ErrDBDataConflict = MakeCError(9101, http.StatusInternalServerError, "db data conflict")
ErrDBDataBroken = MakeCError(9102, http.StatusInternalServerError, "db data broken")
ErrCacheDataConflict = MakeCError(9201, http.StatusInternalServerError, "cache data conflict")
ErrCacheDataBroken = MakeCError(9202, http.StatusInternalServerError, "cache data broken")
ErrMQDataBroken = MakeCError(9301, http.StatusInternalServerError, "message queue data broken")
)
// business,start from 10000
var (
ErrUnknown = MakeCError(10000, http.StatusInternalServerError, "unknown")
ErrReq = MakeCError(10001, http.StatusBadRequest, "request error")
ErrResp = MakeCError(10002, http.StatusInternalServerError, "response error")
ErrSystem = MakeCError(10003, http.StatusInternalServerError, "system error")
ErrToken = MakeCError(10004, http.StatusUnauthorized, "token wrong")
ErrSession = MakeCError(10005, http.StatusUnauthorized, "session wrong")
ErrAccessKey = MakeCError(10006, http.StatusUnauthorized, "access key wrong")
ErrAccessSign = MakeCError(10007, http.StatusUnauthorized, "access sign wrong")
ErrPermission = MakeCError(10008, http.StatusForbidden, "permission denie")
ErrTooFast = MakeCError(10009, http.StatusForbidden, "too fast")
ErrBan = MakeCError(10010, http.StatusForbidden, "ban")
ErrBusy = MakeCError(10011, http.StatusServiceUnavailable, "busy")
ErrNotExist = MakeCError(10012, http.StatusNotFound, "not exist")
ErrAlreadyExist = MakeCError(10013, http.StatusBadRequest, "already exist")
ErrPasswordWrong = MakeCError(10014, http.StatusBadRequest, "password wrong")
ErrPasswordLength = MakeCError(10015, http.StatusBadRequest, "password length must <=32")
)
// convert std error,always -1
var (
ErrDeadlineExceeded = MakeCError(-1, http.StatusGatewayTimeout, context.DeadlineExceeded.Error())
ErrCanceled = MakeCError(-1, http.StatusRequestTimeout, context.Canceled.Error())
)