diff --git a/errors.go b/errors.go index f4743b0a..23fedd7f 100644 --- a/errors.go +++ b/errors.go @@ -13,6 +13,10 @@ var ( CantStartTransaction = errors.New("can't start transaction") ) +type errorsInterface interface { + GetErrors() []error +} + type Errors struct { errors []error } diff --git a/main.go b/main.go index 8457dc96..d1898142 100644 --- a/main.go +++ b/main.go @@ -518,7 +518,11 @@ func (s *DB) AddError(err error) error { s.log(err) } - err = Errors{errors: append(s.GetErrors(), err)} + if e, ok := err.(errorsInterface); ok { + err = Errors{errors: append(s.GetErrors(), e.GetErrors()...)} + } else { + err = Errors{errors: append(s.GetErrors(), err)} + } } s.Error = err @@ -526,10 +530,11 @@ func (s *DB) AddError(err error) error { return err } -func (s *DB) GetErrors() []error { - if errs, ok := s.Error.(Errors); ok { - return errs.errors - } else { +func (s *DB) GetErrors() (errors []error) { + if errs, ok := s.Error.(errorsInterface); ok { + return errs.GetErrors() + } else if s.Error != nil { return []error{s.Error} } + return }