portfree
Version:
A cross-platform CLI tool for managing processes running on specific ports
42 lines • 1.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SystemError = void 0;
/**
* Custom error class for system-related errors
* Used when system commands fail or system resources are unavailable
*/
class SystemError extends Error {
/**
* Create a new SystemError
* @param message - Error message describing the system issue
* @param command - System command that failed (optional)
* @param exitCode - Exit code of the failed command (optional)
*/
constructor(message, command = null, exitCode = null) {
super(message);
this.name = 'SystemError';
this.code = 'SYSTEM_ERROR';
this.command = command;
this.exitCode = exitCode;
// Maintains proper stack trace for where our error was thrown (only available on V8)
if (Error.captureStackTrace) {
Error.captureStackTrace(this, SystemError);
}
}
/**
* Get user-friendly error message with context
* @returns Formatted error message
*/
getUserMessage() {
let message = this.message;
if (this.command) {
message += `\nCommand: ${this.command}`;
}
if (this.exitCode !== null) {
message += `\nExit code: ${this.exitCode}`;
}
return message;
}
}
exports.SystemError = SystemError;
//# sourceMappingURL=system-error.js.map