elasticsearch-streams icon indicating copy to clipboard operation
elasticsearch-streams copied to clipboard

[Enhancement] Get index on error with Writable bulk

Open KoalaMoala opened this issue 6 years ago • 0 comments
trafficstars

Hello there,

I have been using elasticsearch-streams in production for several month and I'm pretty happy with it. However I think I could have an easier time debugging.

I would like to get the index of the error back in the error object. Something like this :

for (var i = 0; i < resp.items.length; i++) {
       var bulkItemResp = resp.items[i];
       var key = Object.keys(bulkItemResp)[0];
        if (bulkItemResp[key].error) {
          var err = new Error(bulkItemResp[key].error.reason || bulkItemResp[key].error);
          err.reason = bulkItemResp[key].error.reason;
          err.type = bulkItemResp[key].error.type;
          err.index = i; // <<< this
          self.emit('error', err);
        }
}

https://github.com/hmalphettes/elasticsearch-streams/blob/master/lib/writable-bulk.js#L88

It would be really helpful to know which object is the source of the error.

KoalaMoala avatar Mar 04 '19 16:03 KoalaMoala