Merge pull request #1058 from braydonf/feature/error-messages-with-docs
Added docs link to InvalidArgument message for preconditions.
This commit is contained in:
commit
138ee5229a
|
@ -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".');
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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…
Reference in New Issue