jb55 / node-bitcoin

zero-dependency bitcoin core rpc lib for nodejs
The Unlicense
45 stars 127 forks source link

It'd be nice to have Error objects. #11

Closed dazoe closed 12 years ago

dazoe commented 12 years ago

It would be nave to have Error objects instead of just plan objects...IE:

function callRpc(cmd, args, rpc) {
  var fn = args[args.length-1];

  // If the last function is a callback, pop it from the args list
  if(_.isFunction(fn)) {
    args.pop();
  } else {
    fn = function () {};
  }

  rpc.call(cmd, args, function(){
    var args = [].slice.call(arguments);
    args.unshift(null);
    fn.apply(this, args);
  }, function(err){
    fn(_.extend(new Error(), err));
  });
}
freewil commented 12 years ago

yup, this should be fixed. I'll look into this soon.