Browse Source

Added docs link to InvalidArgument message for preconditions.

- Error messages will appear as: "Invalid Argument: First argument is required, please include address data. Documentation: http://bitcore.io/guide/address.html"
patch-2
Braydon Fuller 10 years ago
parent
commit
904df59493
  1. 2
      lib/address.js
  2. 5
      lib/errors/spec.js
  3. 4
      lib/util/preconditions.js

2
lib/address.js

@ -58,7 +58,7 @@ function Address(data, network, type) {
return data;
}
$.checkArgument(data, new TypeError('First argument is required, please include address data.'));
$.checkArgument(data, 'First argument is required, please include address data.', 'guide/address.html');
if (network && !Networks.get(network)) {
throw new TypeError('Second argument must be "livenet" or "testnet".');

5
lib/errors/spec.js

@ -1,5 +1,7 @@
'use strict';
var docsURL = 'http://bitcore.io/';
module.exports = [{
name: 'InvalidB58Char',
message: 'Invalid Base58 character: {0} in {1}'
@ -21,7 +23,8 @@ module.exports = [{
}, {
name: 'InvalidArgument',
message: function() {
return 'Invalid Argument' + (arguments[0] ? (': ' + arguments[0]) : '');
return 'Invalid Argument' + (arguments[0] ? (': ' + arguments[0]) : '') +
(arguments[1] ? (' Documentation: ' + docsURL + arguments[1]): '');
}
}, {
name: 'AbstractMethodInvoked',

4
lib/util/preconditions.js

@ -9,9 +9,9 @@ module.exports = {
throw new errors.InvalidState(message);
}
},
checkArgument: function(condition, argumentName, message) {
checkArgument: function(condition, argumentName, message, docsPath) {
if (!condition) {
throw new errors.InvalidArgument(argumentName, message);
throw new errors.InvalidArgument(argumentName, message, docsPath);
}
},
checkArgumentType: function(argument, type, argumentName) {

Loading…
Cancel
Save