sponge/pkg/errcode/grpc_sevice_code.go

21 lines
562 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package errcode
import "google.golang.org/grpc/codes"
// nolint
// rpc服务级别错误码有Status前缀
var (
// StatusUserCreate = NewGRPCStatus(400101, "创建用户失败")
// StatusUserDelete = NewGRPCStatus(400102, "删除用户失败")
// StatusUserUpdate = NewGRPCStatus(400103, "更新用户失败")
// StatusUserGet = NewGRPCStatus(400104, "获取用户失败")
)
// GCode 根据编号生成400000~500000之间的错误码
func GCode(NO int) codes.Code {
if NO > 1000 {
panic("NO must be < 1000")
}
return codes.Code(400000 + NO*100)
}