Documentation ¶
Overview ¶
Package dasherr
充分拓展后的错误类
Fully expanded error class
Index ¶
- Constants
- func GetCodeMsg(code uint32) string
- func ParseCode(code any) uint32
- func RegisterCode(dict map[uint32]string)
- type Dasherr
- func Code(code uint32) *Dasherr
- func Err(err ...error) *Dasherr
- func Log(log string) *Dasherr
- func Logf(format string, a ...any) *Dasherr
- func Msg(msg string) *Dasherr
- func Msgf(format string, a ...any) *Dasherr
- func New(err ...error) *Dasherr
- func Pre(msg string) *Dasherr
- func Pref(format string, a ...any) *Dasherr
- func (m *Dasherr) Code(code uint32) *Dasherr
- func (m *Dasherr) Err(err error) *Dasherr
- func (m *Dasherr) Error() string
- func (m *Dasherr) Log(log string) *Dasherr
- func (m *Dasherr) Logf(format string, a ...any) *Dasherr
- func (m *Dasherr) Msg(msg string) *Dasherr
- func (m *Dasherr) Msgf(format string, a ...any) *Dasherr
- func (m *Dasherr) Pre(prefix string) *Dasherr
- func (m *Dasherr) Pref(format string, a ...any) *Dasherr
- type RpcError
Constants ¶
View Source
const ( CodeOK = uint32(0) //成功 CodeUnknown = 9999 + uint32(iota) //未知错误 CodeCanceled // 操作被取消 CodeInvalidArgument // 无效参数 CodeDeadlineExceeded // 操作超过截止日期 CodeNotFound // 请求实体未找到 CodeAlreadyExists // 请求实体已存在 CodePermissionDenied // 权限拒绝 CodeResourceExhausted // 资源已经耗尽 CodeFailedPrecondition // 先决条件失败 CodeAborted // 操作已中止 CodeOutOfRange // 操作值溢出 CodeUnimplemented // 未实现操作 CodeInternal // 内部错误 CodeDataLoss // 数据丢失或损坏 CodeUnauthenticated // 未认证或凭证无效 CodeExternalGrpcError // 外部通信错误 CodeMax = 19999 // Dasherr Max Code )
常规错误码 errdash code [10000~20000)
Variables ¶
This section is empty.
Functions ¶
func GetCodeMsg ¶
GetCodeMsg @Editor robotyang at 2023
GetCodeMsg 转义 code 为对应中文含义 ¶
@Param code 可能是 grpc code、errdash code 的 uint32 或 codes.Code;
func ParseCode ¶
ParseCode @Editor robotyang at 2023
ParseCode 解析 code 对应的 errdash code ¶
@Param code 可能是 grpc code、errdash code 的 uint32 或 codes.Code;
func RegisterCode ¶
RegisterCode @Editor robotyang at 2023
RegisterCode 注册错误字典 ¶
@Param dict 要注册的错误字段(建议尽量注册 >= 20000 的 code)
Types ¶
type Dasherr ¶
type Dasherr struct { Pres string //错误信息前缀 Codes uint32 //错误码 Msgs string //错误信息(用户看) Logs []string //日志信息(开发看) Stack []string //调用堆栈(开发看) }
Dasherr error struct
Click to show internal directories.
Click to hide internal directories.