diff --git a/errors/errors.go b/errors/errors.go index f48fbe95..4e6816c6 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -167,8 +167,8 @@ func NewMultiError() *MultiError { } } -func (e *MultiError) Append(err *Error) { - e.Errors = append(e.Errors, err) +func (e *MultiError) Append(err ...*Error) { + e.Errors = append(e.Errors, err...) } func (e *MultiError) HasErrors() bool { diff --git a/errors/errors_test.go b/errors/errors_test.go index f50ec7a4..bc62dfba 100644 --- a/errors/errors_test.go +++ b/errors/errors_test.go @@ -121,14 +121,7 @@ func TestAppend(t *testing.T) { }, } - for _, e := range testData { - mError.Append(&Error{ - Id: e.Id, - Code: e.Code, - Detail: e.Detail, - Status: e.Status, - }) - } + mError.Append(testData...) if len(mError.Errors) != 3 { t.Fatalf("Expected 3 got %v", len(mError.Errors)) @@ -162,14 +155,7 @@ func TestHasErrors(t *testing.T) { t.Fatal("Expected no error") } - for _, e := range testData { - mError.Errors = append(mError.Errors, &Error{ - Id: e.Id, - Code: e.Code, - Detail: e.Detail, - Status: e.Status, - }) - } + mError.Append(testData...) if !mError.HasErrors() { t.Fatal("Expected errors")