Skip to content

Commit 63167c8

Browse files
author
Tomaž Žinko
authored
Merge pull request #3 from hellofresh/fix/panic-empty-events
Returns an error if events are empty
2 parents 5fe9093 + 2f29f16 commit 63167c8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

aggregate_repository.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package goengine
22

33
import (
4+
"fmt"
45
log "github.com/Sirupsen/logrus"
56
)
67

@@ -58,6 +59,10 @@ func (r *PublisherRepository) Reconstitute(id string, source AggregateRoot, stre
5859
}
5960
events := stream.Events
6061

62+
if len(events) == 0 {
63+
return fmt.Errorf("No events found for id: %s", id)
64+
}
65+
6166
for _, event := range events {
6267
source.Apply(event.Payload)
6368
}

0 commit comments

Comments
 (0)