Skip to content
Myr

error.js

This file

Path

lib/error.js

36 lines · 1.1 KiB · JavaScript

Last changed by

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

History of this file

Take it

The walk stopped after 200 commits: lines older than 471ec40 point at it.

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 1–3why, one step back
1/**
2 * CommanderError class3 */

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

line 4why, one step back
4export class CommanderError extends Error {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 5–24why, one step back
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 */

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

line 25why, one step back
25export class InvalidArgumentError extends CommanderError {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 26–36why, one step back
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}