error.js
This file
Path
lib/error.js
39 lines · 1.1 KiB · JavaScript
Last changed by
Fix some JSDoc lint issues (#2181)John Geebefore adoptionb95ea44
History of this fileTake it
The walk stopped after 200 commits: lines older than 3103c6b point at it.
Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 1–39why, one step back1/**2 * CommanderError class3 */4class CommanderError extends Error {5 /**6 * Constructs the CommanderError class7 * @param {number} exitCode suggested exit code which could be used with process.exit8 * @param {string} code an id string representing the error9 * @param {string} message human-readable description of the error10 */11 constructor(exitCode, code, message) {12 super(message);13 // properly capture stack trace in Node.js14 Error.captureStackTrace(this, this.constructor);15 this.name = this.constructor.name;16 this.code = code;17 this.exitCode = exitCode;18 this.nestedError = undefined;19 }20}2122/**23 * InvalidArgumentError class24 */25class InvalidArgumentError extends CommanderError {26 /**27 * Constructs the InvalidArgumentError class28 * @param {string} [message] explanation of why argument is invalid29 */30 constructor(message) {31 super(1, 'commander.invalidArgument', message);32 // properly capture stack trace in Node.js33 Error.captureStackTrace(this, this.constructor);34 this.name = this.constructor.name;35 }36}3738exports.CommanderError = CommanderError;39exports.InvalidArgumentError = InvalidArgumentError;