Erros skip nil in Add function (#1566)

This commit is contained in:
Teppei Fukuda 2017-09-04 22:25:57 +08:00 committed by Jinzhu
parent 981d5db663
commit 6e456250f7
1 changed files with 4 additions and 0 deletions

View File

@ -29,6 +29,10 @@ func (errs Errors) GetErrors() []error {
// Add adds an error // Add adds an error
func (errs Errors) Add(newErrors ...error) Errors { func (errs Errors) Add(newErrors ...error) Errors {
for _, err := range newErrors { for _, err := range newErrors {
if err == nil {
continue
}
if errors, ok := err.(Errors); ok { if errors, ok := err.(Errors); ok {
errs = errs.Add(errors...) errs = errs.Add(errors...)
} else { } else {