mirror of
https://github.com/go-micro/go-micro.git
synced 2025-05-31 21:59:42 +02:00
feat(errors): append errors use variadic arguments (#2606)
This commit is contained in:
parent
68a6425ad8
commit
ad0b4f103d
@ -167,8 +167,8 @@ func NewMultiError() *MultiError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *MultiError) Append(err *Error) {
|
func (e *MultiError) Append(err ...*Error) {
|
||||||
e.Errors = append(e.Errors, err)
|
e.Errors = append(e.Errors, err...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *MultiError) HasErrors() bool {
|
func (e *MultiError) HasErrors() bool {
|
||||||
|
@ -121,14 +121,7 @@ func TestAppend(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, e := range testData {
|
mError.Append(testData...)
|
||||||
mError.Append(&Error{
|
|
||||||
Id: e.Id,
|
|
||||||
Code: e.Code,
|
|
||||||
Detail: e.Detail,
|
|
||||||
Status: e.Status,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(mError.Errors) != 3 {
|
if len(mError.Errors) != 3 {
|
||||||
t.Fatalf("Expected 3 got %v", len(mError.Errors))
|
t.Fatalf("Expected 3 got %v", len(mError.Errors))
|
||||||
@ -162,14 +155,7 @@ func TestHasErrors(t *testing.T) {
|
|||||||
t.Fatal("Expected no error")
|
t.Fatal("Expected no error")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, e := range testData {
|
mError.Append(testData...)
|
||||||
mError.Errors = append(mError.Errors, &Error{
|
|
||||||
Id: e.Id,
|
|
||||||
Code: e.Code,
|
|
||||||
Detail: e.Detail,
|
|
||||||
Status: e.Status,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if !mError.HasErrors() {
|
if !mError.HasErrors() {
|
||||||
t.Fatal("Expected errors")
|
t.Fatal("Expected errors")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user