errors
errors copied to clipboard
基于github.com/pkg/errors包,增加对error code的支持,完全兼容github.com/pkg/errors
我有一个函数: ```go func Create () error{ return errors.WithCode(errcode.Create, "创建错误") } ``` 测试中一般这样写: ```go testCases := []struct { name string wantErr error }{ name: "xxx", wantErr: errors.WithCode(errcode.Create, "创建错误") } } for...
`func (u *userRepo)Info(ctx context.Context) error { return errors.WithCode(code.ErrDatabase, "data 层 user info 操作失败%s","test") }` `fmt.Println(fmt.Sprintf("== == %s", err))` 输出的日志是空的
From Register/MustRegister method, we can known defaultCode.C should be 0, so I think maybe it should keep the same rule.