Skip to content
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

Add nice error when forgetting to add a sourceId for an event in aggregates #89

Open
rhyslbw opened this issue Apr 25, 2016 · 0 comments

Comments

@rhyslbw
Copy link
Member

rhyslbw commented Apr 25, 2016

This is a really easy mistake to make particularly for someone new. Currently if you omit the sourceId from an event, this is thrown:

TypeError: Cannot call method 'toString' of undefined
    at Asset.Space.eventSourcing.Aggregate.Aggregate._validateEvent (packages/space_event-sourcing/source/server/domain/aggregate.coffee:119:27)
    at Asset.Space.eventSourcing.Aggregate.Aggregate.record (packages/space_event-sourcing/source/server/domain/aggregate.coffee:79:6)
    at Asset._myCommandHandler (packages/myPackage/src/domain/myAggregate.js:64:17)
    at Asset.Space.eventSourcing.Aggregate.Aggregate.handle (packages/space_event-sourcing/source/server/domain/aggregate.coffee:95:27)
    at AssetRouter.<anonymous> (packages/space_event-sourcing/source/server/infrastructure/router.coffee:93:65)
    at AssetRouter.Space.eventSourcing.Router.Router._handleDomainErrors (packages/space_event-sourcing/source/server/infrastructure/router.coffee:102:17)
    at AssetRouter.Space.eventSourcing.Router.Router.messageHandler (packages/space_event-sourcing/source/server/infrastructure/router.coffee:93:26)
    at packages/space_event-sourcing/source/server/infrastructure/router.coffee:1:1
    at CommandBus.Space.messaging.CommandBus.CommandBus.send (packages/space_messaging/source/command_bus.coffee:25:7)
    at [object Object]:1:-11

-> ${eventType} in ${aggregate} is missing a sourceId. Add sourceId: this.getId() to this event

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants