4 var format = require('util').format;
7 var ERR_CODE = 'ARGError';
10 * argumentError(argument, message) -> TypeError
11 * - argument (Object): action with broken argument
12 * - message (String): error message
14 * Error format helper. An error from creating or using an argument
15 * (optional or positional). The string value of this exception
16 * is the message, augmented with information
17 * about the argument that caused it.
21 * var argumentErrorHelper = require('./argument/error');
22 * if (conflictOptionals.length > 0) {
23 * throw argumentErrorHelper(
25 * format('Conflicting option string(s): %s', conflictOptionals.join(', '))
30 module.exports = function (argument, message) {
31 var argumentName = null;
35 if (argument.getName) {
36 argumentName = argument.getName();
38 argumentName = '' + argument;
44 errMessage = format('argument "%s": %s', argumentName, message);
47 err = new TypeError(errMessage);