Merge pull request #1058 from braydonf/feature/error-messages-with-docs

Added docs link to InvalidArgument message for preconditions.
This commit is contained in:
Esteban Ordano 2015-02-10 09:56:57 -03:00
commit 138ee5229a
3 changed files with 7 additions and 4 deletions

View File

@ -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".');

View File

@ -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',

View File

@ -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) {