Skip to content

Commit

Permalink
Merge pull request #273 from wepala/feature/event-error
Browse files Browse the repository at this point in the history
Feature/event error
  • Loading branch information
akeemphilbert authored Jan 23, 2024
2 parents 2e22528 + c95f20c commit 940961d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion model/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,18 @@ func (e *EventRepositoryGorm) Persist(ctxt context.Context, entity AggregateInte
//call persist on the aggregate root to clear the new changes array
entity.Persist()

var errs []error
for _, entity := range entities {
e.eventDispatcher.Dispatch(ctxt, *entity.(*Event))
errors := e.eventDispatcher.Dispatch(ctxt, *entity.(*Event))
if len(errors) > 0 {
errs = append(errs, errors...)
}
}

if len(errs) > 0 {
return errs[0]
}

return nil
}

Expand Down

0 comments on commit 940961d

Please sign in to comment.