marmotedu / errors Goto Github PK
View Code? Open in Web Editor NEW基于github.com/pkg/errors包,增加对error code的支持,完全兼容github.com/pkg/errors
License: Other
基于github.com/pkg/errors包,增加对error code的支持,完全兼容github.com/pkg/errors
License: Other
func (u *userRepo)Info(ctx context.Context) error { return errors.WithCode(code.ErrDatabase, "data 层 user info 操作失败%s","test") }
fmt.Println(fmt.Sprintf("== == %s", err))
输出的日志是空的
我有一个函数:
func Create () error{
return errors.WithCode(errcode.Create, "创建错误")
}
测试中一般这样写:
testCases := []struct {
name string
wantErr error
}{
name: "xxx",
wantErr: errors.WithCode(errcode.Create, "创建错误")
}
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T)) {
err := Create()
assert.Equal(t, tc.wantErr, err)
}
}
类似上面的并不会比较成功,现在只能人眼打印去看具体的信息,有什么优雅的方法吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.