diff --git a/errors.go b/errors.go index 23fedd7f..9dfcd2e9 100644 --- a/errors.go +++ b/errors.go @@ -26,7 +26,18 @@ func (errs Errors) GetErrors() []error { } func (errs *Errors) Add(err error) { - errs.errors = append(errs.errors, err) + if errors, ok := err.(errorsInterface); ok { + for _, err := range errors.GetErrors() { + errs.Add(err) + } + } else { + for _, e := range errs.errors { + if err == e { + return + } + } + errs.errors = append(errs.errors, err) + } } func (errs Errors) Error() string { diff --git a/main.go b/main.go index d1898142..50aeb49c 100644 --- a/main.go +++ b/main.go @@ -518,10 +518,10 @@ func (s *DB) AddError(err error) error { s.log(err) } - if e, ok := err.(errorsInterface); ok { - err = Errors{errors: append(s.GetErrors(), e.GetErrors()...)} - } else { - err = Errors{errors: append(s.GetErrors(), err)} + errors := Errors{errors: s.GetErrors()} + errors.Add(err) + if len(errors.GetErrors()) > 1 { + err = errors } }