code.go 641 Bytes
Newer Older
kzkzzzz's avatar
kzkzzzz committed
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
package errm

type ErrorCode int

const (
	CommonErrorCode   ErrorCode = 1000
	ParamsErrorCode             = 1001
	NotFoundErrorCode           = 1002
	ServiceErrorCode            = 1003
	DbErrorCode                 = 1004
	SystemErrorCode             = 9999
)

var (
	codeText = map[ErrorCode]string{
		CommonErrorCode:   "error",
		ParamsErrorCode:   "params error",
		NotFoundErrorCode: "not found error",
		DbErrorCode:       "db error",
		ServiceErrorCode:  "service error",
		SystemErrorCode:   "system error",
	}
)

func GetCodeText(code ErrorCode) string {
	if v, ok := codeText[code]; ok {
		return v
	} else {
		return "error"
	}
}