bmavity / ges-client

A node.js client library for (Get) Event Store
Other
30 stars 9 forks source link

Properly identify operation errors #43

Open bmavity opened 9 years ago

bmavity commented 9 years ago

If a server response message has an .error property, the operation code still identifies it as a successful response and does not report an error.

Code to reproduce an example

var ges = require('ges-client')
    , connection = ges({})

module.exports.readStream = readStream

function readStream(streamName, cb) {
    connection.readStreamEventsForward(streamName, function(err, events) {
        if(err) return cb(err)

        cb(err, events)
    })
}

With response

{ auth: undefined,
  cb: undefined,
  requestType: 'ReadStreamEventsForward',
  toRequestPayload: [Function],
  responseType: 'ReadStreamEventsCompleted',
  toResponseObject: [Function] } { result: 'Error',
  nextEventNumber: -1,
  lastEventNumber: -1,
  isEndOfStream: true,
  lastCommitPosition: '3463749',
  error: 'maxCount should be positive.\nParameter name: maxCount' }