mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
This should make it possible to test out the creation of Single Executable Applications on a PR without making outbound requests to download and run postject using npm. This is needed for https://github.com/nodejs/node/pull/45038. Refs: https://github.com/nodejs/single-executable/blob/1840f3d9c5f4fa0d29aabd5618c4ff9745f7be87/meetings/2022-10-31.md?plain=1#L75-L76 Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: https://github.com/nodejs/node/pull/45298 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tierney Cyren <hello@bnb.im>
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
// @ts-check
|
|
|
|
/**
|
|
* CommanderError class
|
|
* @class
|
|
*/
|
|
class CommanderError extends Error {
|
|
/**
|
|
* Constructs the CommanderError class
|
|
* @param {number} exitCode suggested exit code which could be used with process.exit
|
|
* @param {string} code an id string representing the error
|
|
* @param {string} message human-readable description of the error
|
|
* @constructor
|
|
*/
|
|
constructor(exitCode, code, message) {
|
|
super(message);
|
|
// properly capture stack trace in Node.js
|
|
Error.captureStackTrace(this, this.constructor);
|
|
this.name = this.constructor.name;
|
|
this.code = code;
|
|
this.exitCode = exitCode;
|
|
this.nestedError = undefined;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* InvalidArgumentError class
|
|
* @class
|
|
*/
|
|
class InvalidArgumentError extends CommanderError {
|
|
/**
|
|
* Constructs the InvalidArgumentError class
|
|
* @param {string} [message] explanation of why argument is invalid
|
|
* @constructor
|
|
*/
|
|
constructor(message) {
|
|
super(1, 'commander.invalidArgument', message);
|
|
// properly capture stack trace in Node.js
|
|
Error.captureStackTrace(this, this.constructor);
|
|
this.name = this.constructor.name;
|
|
}
|
|
}
|
|
|
|
exports.CommanderError = CommanderError;
|
|
exports.InvalidArgumentError = InvalidArgumentError;
|