未验证 提交 532d12c4 编写于 作者: Y yah01 提交者: GitHub

Fix the code lost with multi errors (#22877)

Signed-off-by: Nyah01 <yang.cen@zilliz.com>
上级 4c603cd0
......@@ -166,6 +166,12 @@ func (e multiErrors) Unwrap() error {
if len(e.errs) <= 1 {
return nil
}
// To make merr work for multi errors,
// we need cause of multi errors, which defined as the last error
if len(e.errs) == 2 {
return e.errs[1]
}
return multiErrors{
errs: e.errs[1:],
}
......
......@@ -138,6 +138,11 @@ func (s *ErrSuite) TestCombineOnlyNil() {
s.Nil(err)
}
func (s *ErrSuite) TestCombineCode() {
err := Combine(WrapErrIoFailed("test"), WrapErrCollectionNotFound(1))
s.Equal(Code(ErrCollectionNotFound), Code(err))
}
func TestErrors(t *testing.T) {
suite.Run(t, new(ErrSuite))
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册