Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( StatusSuccess = NewGRPCStatus(0, "ok") StatusInvalidParams = NewGRPCStatus(300001, "参数错误") StatusInternalServerError = NewGRPCStatus(300003, "服务内部错误") StatusNotFound = NewGRPCStatus(300004, "资源不存在") StatusAlreadyExists = NewGRPCStatus(300005, "资源已存在") StatusTimeout = NewGRPCStatus(300006, "访问超时") StatusTooManyRequests = NewGRPCStatus(300007, "请求过多") StatusForbidden = NewGRPCStatus(300008, "拒绝访问") StatusLimitExceed = NewGRPCStatus(300009, "访问限制") StatusDeadlineExceeded = NewGRPCStatus(300010, "已超过最后期限") StatusAccessDenied = NewGRPCStatus(300011, "拒绝访问") StatusMethodNotAllowed = NewGRPCStatus(300012, "不允许使用的方法") )
nolint rpc系统级别错误码,有status前缀
View Source
var ( Success = NewError(0, "ok") InvalidParams = NewError(100001, "参数错误") InternalServerError = NewError(100003, "服务内部错误") NotFound = NewError(100004, "资源不存在") AlreadyExists = NewError(100005, "资源已存在") Timeout = NewError(100006, "超时") TooManyRequests = NewError(100007, "请求过多") Forbidden = NewError(100008, "拒绝访问") LimitExceed = NewError(100009, "访问限制") DeadlineExceeded = NewError(100010, "已超过最后期限") AccessDenied = NewError(100011, "拒绝访问") MethodNotAllowed = NewError(100012, "不允许使用的方法") )
nolint http系统级别错误码,无Err前缀
Functions ¶
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error 错误
func (*Error) WithDetails ¶
WithDetails 携带附加错误详情
type GRPCStatus ¶
type GRPCStatus struct {
// contains filtered or unexported fields
}
GRPCStatus grpc 状态
func NewGRPCStatus ¶
func NewGRPCStatus(code codes.Code, msg string) *GRPCStatus
NewGRPCStatus 新建一个status
func (*GRPCStatus) ToRPCCode ¶
func (g *GRPCStatus) ToRPCCode() codes.Code
ToRPCCode converted to standard RPC error code
func (*GRPCStatus) ToRPCErr ¶
func (g *GRPCStatus) ToRPCErr(desc ...string) error
ToRPCErr converted to standard RPC error
Click to show internal directories.
Click to hide internal directories.