Skip to content
Myr

error.js

This file

Path

lib/error.js

43 lines · 1.2 KiB · JavaScript

Last changed by

Merge branch 'develop' into release/12.xJohn Geebefore adoption72e6f7a

History of this file

Take it

Refactor classes into files (#1522)John Geebefore adoption08245cc

lines 1–43why, one step back
1/**
2 * CommanderError class3 * @class4 */5class CommanderError extends Error {6 /**7 * Constructs the CommanderError class8 * @param {number} exitCode suggested exit code which could be used with process.exit9 * @param {string} code an id string representing the error10 * @param {string} message human-readable description of the error11 * @constructor12 */13 constructor(exitCode, code, message) {14 super(message);15 // properly capture stack trace in Node.js16 Error.captureStackTrace(this, this.constructor);17 this.name = this.constructor.name;18 this.code = code;19 this.exitCode = exitCode;20 this.nestedError = undefined;21 }22}2324/**25 * InvalidArgumentError class26 * @class27 */28class InvalidArgumentError extends CommanderError {29 /**30 * Constructs the InvalidArgumentError class31 * @param {string} [message] explanation of why argument is invalid32 * @constructor33 */34 constructor(message) {35 super(1, 'commander.invalidArgument', message);36 // properly capture stack trace in Node.js37 Error.captureStackTrace(this, this.constructor);38 this.name = this.constructor.name;39 }40}4142exports.CommanderError = CommanderError;43exports.InvalidArgumentError = InvalidArgumentError;