meteor-space / event-sourcing

CQRS and Event Sourcing Infrastructure for Meteor.
MIT License
63 stars 9 forks source link

Returning Space.Error from Router rather than null #94

Closed rhyslbw closed 8 years ago

rhyslbw commented 8 years ago
_handleDomainErrors: (fn) ->
    try
      return fn.call(this)
    catch error
      if error instanceof Space.Error
        this.publish(new Space.domain.Exception({
          thrower: @eventSourceable.toString(),
          error: error
        }))
        return null
      else
        throw error

We should really be returning the Space.Error after publishing, rather than returning null. While the original intent was rooted in CQRS theory, we're currently we're relying on subscription to the server-side event bus and specific implementation for pass this down into the client 👎

This is a bug IMO as an error is not a query response, it's negative acknowledgement (nack).

Thoughts @meteor-space/core ?

DominikGuzei commented 8 years ago

Good call! 👍