MCPcopy
hub / github.com/tj/commander.js / error

Method error

lib/command.js:1952–1970  ·  view source on GitHub ↗

* Display error message and exit (or call exitOverride). * * @param {string} message * @param {object} [errorOptions] * @param {string} [errorOptions.code] - an id string representing the error * @param {number} [errorOptions.exitCode] - used with process.exit

(message, errorOptions)

Source from the content-addressed store, hash-verified

1950 * @param {number} [errorOptions.exitCode] - used with process.exit
1951 */
1952 error(message, errorOptions) {
1953 // output handling
1954 this._outputConfiguration.outputError(
1955 `${message}\n`,
1956 this._outputConfiguration.writeErr,
1957 );
1958 if (typeof this._showHelpAfterError === 'string') {
1959 this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`);
1960 } else if (this._showHelpAfterError) {
1961 this._outputConfiguration.writeErr('\n');
1962 this.outputHelp({ error: true });
1963 }
1964
1965 // exit handling
1966 const config = errorOptions || {};
1967 const exitCode = config.exitCode || 1;
1968 const code = config.code || 'commander.error';
1969 this._exit(exitCode, code, message);
1970 }
1971
1972 /**
1973 * Apply any option related environment variables, if option does

Callers 13

_callParseArgMethod · 0.95
missingArgumentMethod · 0.95
optionMissingArgumentMethod · 0.95
_conflictingOptionMethod · 0.95
unknownOptionMethod · 0.95
_excessArgumentsMethod · 0.95
unknownCommandMethod · 0.95
action-this.jsFile · 0.80
thank.jsFile · 0.80

Calls 4

outputHelpMethod · 0.95
_exitMethod · 0.95
outputErrorMethod · 0.80
writeErrMethod · 0.80

Tested by

no test coverage detected