Skip to content

Aggregate throws an error when snapshot type is not registered #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions source/server/domain/aggregate.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Space.eventSourcing.Aggregate extends Space.Object
domainEventRequired: "#{Aggregate}: Event must inherit from Space.domain.Event"
cannotHandleMessage: "#{Aggregate}: Cannot handle: "
invalidEventSourceId: "#{Aggregate}: The given event has an invalid source id."
undefinedSnapshotTpe: "#{Aggregate}: Snapshot type is undefined. Did you forget to call: #{Aggregate}.registerSnapshotType()?"
}

@createFromHistory: (events) -> new this(events[0].sourceId, events)
Expand Down Expand Up @@ -58,6 +59,7 @@ class Space.eventSourcing.Aggregate extends Space.Object
getEvents: -> @_events

getSnapshot: ->
unless @constructor._snapshotType? then throw new Error Aggregate::ERRORS.undefinedSnapshotTpe
data = {}
data.id = @_id
data.state = @_state
Expand Down