mapbox / dyno

simple dynamodb client
MIT License
78 stars 31 forks source link

Attach request ids to error objects #109

Closed rclark closed 8 years ago

rclark commented 8 years ago

Dyno could insure that an error object always comes with request ids attached if this doesn't get implemented upstream.

Basically, instead of passing through native aws-sdk functions, we would write small wrappers. For example, from index.js:

// this is what we do now
var dyno = {
  putItem: docClient.put.bind(docClient)
};

// we could, instead
var dyno = {
  putItem: function(params, callback) {
    return docClient.put(params, callback)
      .on('retry', function(response) {
        if (!response.error) return;
        response.error.amzId = response.httpResponse.headers['x-amz-request-id'];
        response.error.amzId2 = response.httpResponse.headers['x-amz-id-2'];
      });
  }
}

cc @willwhite

rclark commented 8 years ago

The aws-sdk itself does this pretty well now.