bitpay / bitcore-explorers

Blockchain APIs for bitcore
http://bitcore.io
MIT License
67 stars 95 forks source link

Catch validation exception and return error in callback #17

Closed isocolsky closed 9 years ago

isocolsky commented 9 years ago

This PR adds robustness to the interaction with the Insight server.

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.21%) to 91.46% when pulling d993dc0f2410a32168fd26ee3e0ae380ce46899a on isocolsky:fix/insight_response into 21c8c9eff1b2a157285064940a0bd9a8db959a9b on bitpay:master.

isocolsky commented 9 years ago

Ok, I'm catching the InvalidArgument error. It works but it is not perfect because of this code in Bitcore.Transaction:

  if (!txId || !JSUtil.isHexaString(txId) || txId.length > 64) {
    // TODO: Use the errors library
    throw new Error('Invalid TXID in object', data);
  }
  var outputIndex = _.isUndefined(data.vout) ? data.outputIndex : data.vout;
  if (!_.isNumber(outputIndex)) {
    throw new Error('Invalid outputIndex, received ' + outputIndex);
  }
coveralls commented 9 years ago

Coverage Status

Coverage decreased (-21.37%) to 69.88% when pulling 69ff76659722366cf87c0cd6bb4ed59deea28ab5 on isocolsky:fix/insight_response into 21c8c9eff1b2a157285064940a0bd9a8db959a9b on bitpay:master.

maraoz commented 9 years ago

@isocolsky i'll open an issue to fix those error types. https://github.com/bitpay/bitcore/issues/1178

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.32%) to 91.57% when pulling f11a164698ecd9a2cd897966607f97a5fdf051b4 on isocolsky:fix/insight_response into 21c8c9eff1b2a157285064940a0bd9a8db959a9b on bitpay:master.