diff options
author | Sam Ruby <rubys@intertwingly.net> | 2018-06-23 15:42:12 -0400 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-07-20 13:37:40 -0700 |
commit | 946686521dab15d7725af9d28f4bfd5596ba27d6 (patch) | |
tree | cc42eda0db8f46bbe014f426084bb72211dcccc8 /tools/doc/node_modules/argparse/lib/argument/error.js | |
parent | 1ffd35310a5fa5ba0a5b0df963c70287ce004cc5 (diff) | |
download | android-node-v8-946686521dab15d7725af9d28f4bfd5596ba27d6.tar.gz android-node-v8-946686521dab15d7725af9d28f4bfd5596ba27d6.tar.bz2 android-node-v8-946686521dab15d7725af9d28f4bfd5596ba27d6.zip |
tools: create HTML docs with unified/remark/rehype
PR-URL: https://github.com/nodejs/node/pull/21490
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'tools/doc/node_modules/argparse/lib/argument/error.js')
-rw-r--r-- | tools/doc/node_modules/argparse/lib/argument/error.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tools/doc/node_modules/argparse/lib/argument/error.js b/tools/doc/node_modules/argparse/lib/argument/error.js new file mode 100644 index 0000000000..c8a02a08b8 --- /dev/null +++ b/tools/doc/node_modules/argparse/lib/argument/error.js @@ -0,0 +1,50 @@ +'use strict'; + + +var format = require('util').format; + + +var ERR_CODE = 'ARGError'; + +/*:nodoc:* + * argumentError(argument, message) -> TypeError + * - argument (Object): action with broken argument + * - message (String): error message + * + * Error format helper. An error from creating or using an argument + * (optional or positional). The string value of this exception + * is the message, augmented with information + * about the argument that caused it. + * + * #####Example + * + * var argumentErrorHelper = require('./argument/error'); + * if (conflictOptionals.length > 0) { + * throw argumentErrorHelper( + * action, + * format('Conflicting option string(s): %s', conflictOptionals.join(', ')) + * ); + * } + * + **/ +module.exports = function (argument, message) { + var argumentName = null; + var errMessage; + var err; + + if (argument.getName) { + argumentName = argument.getName(); + } else { + argumentName = '' + argument; + } + + if (!argumentName) { + errMessage = message; + } else { + errMessage = format('argument "%s": %s', argumentName, message); + } + + err = new TypeError(errMessage); + err.code = ERR_CODE; + return err; +}; |