Client Errors

When using Rails Event Store you have to be prepared for following errors:


Occurs when other writer has written to the same stream as we intended to and last stream version has changed:

client.publish(, stream_name: 'Order$1', expected_version: 0)

expect do
  client.publish(, stream_name: 'Order$1', expected_version: 0) raise_error(WrongExpectedEventVersion)

Second write to the stream should have happened with expected_version: 1 above.


Occurs when you're writing same event more than once.

order_placed =
client.publish(order_placed, stream_name: 'Order$1', expected_version: 0)

expect do
  client.publish(order_placed, stream_name: 'Order$1', expected_version: 1) raise_error(WrongExpectedEventVersion)

If you want to have an event present in multiple streams, you have to link it with link.


Occurs when invalid exception_version is passed in append_to_stream, link_to_stream or publish. Valid values are Integer or one of :any, :none, :auto.

expect do
  client.append(, stream_name: 'Order$1', expected_version: nil) raise_error(InvalidExpectedVersion)


Occurs when invalid stream_name is passed in any client method expecting it. Name must not be nil or empty string.

expect do
  client.append(, stream_name: nil) raise_error(IncorrectStreamData)


Occurs when event of given id cannot be found. This can happen either when looking for particular event details via read_event or when reading stream, starting from given event.

none_such_id = SecureRandom.uuid
expect do'Order$1').from(none_such_id).to_a raise_error(EventNotFound)


Occurs when reading a stream with invalid start parameter passed. Must not be nil or empty string.

expect do'Order$1').from(nil).to_a raise_error(InvalidPageStart)


Occurs when reading a stream with invalid to parameter passed. Must not be nil or empty string.

expect do'Order$1').to(nil).to_a raise_error(InvalidPageStop)


Occurs when expecting to read less than one event from a stream:

expect do'Order$1').limit(-1).to_a raise_error(InvalidPageSize)


Occurs when given subscriber is nil.

expect do
  client.subscribe(nil, to: [OrderPlaced]) raise_error(SubscriberNotExist)


Occurs when given subscriber is not a valid handler to given dispatcher.

subscriber =
expect do
  client.subscribe(subscriber, to: [OrderPlaced]) raise_error(InvalidHandler)


Occurs when passing stream name of all when using RailsEventStoreActiveRecord of RubyEventStore::ROM repository. This stream name is used internally to implement global stream. Use dedicated global stream readers in order to read events from it.


Raised when event's data is not serializable by RubyEventStore::Mappers::Protobuf.