{"size": 676, "ext": "js", "max_stars_repo_path": "JsonRpcError.js", "max_stars_repo_name": "Ti-webdev/node-routing-json-schema", "max_stars_repo_stars_event_min_datetime": "2019-12-17T16:08:24.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-17T16:08:24.000Z", "max_issues_repo_path": "JsonRpcError.js", "max_issues_repo_name": "Ti-webdev/node-routing-json-schema", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "JsonRpcError.js", "max_forks_repo_name": "Ti-webdev/node-routing-json-schema", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.8064516129, "max_line_length": 86, "alphanum_fraction": 0.6671597633}
var util = require('util');

var JsonRpcError = function(code, message) {
  var formatArgs;

  if (code.code && code.message) {
    message = code.message;
    code    = code.code;
    formatArgs = 1;
  }
  else {
    formatArgs = 2;
  }
  if (formatArgs < arguments.length) {
    message = util.format(message, Array.prototype.slice.call(arguments, formatArgs));
  }
  if (this instanceof JsonRpcError) {
    this.code = code;
    this.message = message;
    Error.captureStackTrace(this, JsonRpcError);
  }
  else {
    return new Error(code, message);
  }
}

util.inherits(JsonRpcError, Error);
JsonRpcError.prototype.name = 'JsonRpcError';

module.exports = JsonRpcError;
