vde-layout
Version:
Terminal multiplexer layout management tool for VDE (Vibe Coding Development Environment)
131 lines • 4.86 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorCodes = exports.EnvironmentError = exports.TmuxError = exports.ValidationError = exports.ConfigError = exports.VDELayoutError = void 0;
exports.isVDELayoutError = isVDELayoutError;
exports.formatError = formatError;
class VDELayoutError extends Error {
code;
details;
constructor(message, code, details = {}) {
super(message);
this.name = "VDELayoutError";
this.code = code;
this.details = details;
Object.setPrototypeOf(this, VDELayoutError.prototype);
}
}
exports.VDELayoutError = VDELayoutError;
class ConfigError extends VDELayoutError {
constructor(message, code, details = {}) {
super(message, code, details);
this.name = "ConfigError";
Object.setPrototypeOf(this, ConfigError.prototype);
}
}
exports.ConfigError = ConfigError;
class ValidationError extends VDELayoutError {
constructor(message, code, details = {}) {
super(message, code, details);
this.name = "ValidationError";
Object.setPrototypeOf(this, ValidationError.prototype);
}
}
exports.ValidationError = ValidationError;
class TmuxError extends VDELayoutError {
constructor(message, code, details = {}) {
super(message, code, details);
this.name = "TmuxError";
Object.setPrototypeOf(this, TmuxError.prototype);
}
}
exports.TmuxError = TmuxError;
class EnvironmentError extends VDELayoutError {
constructor(message, code, details = {}) {
super(message, code, details);
this.name = "EnvironmentError";
Object.setPrototypeOf(this, EnvironmentError.prototype);
}
}
exports.EnvironmentError = EnvironmentError;
exports.ErrorCodes = {
CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND",
CONFIG_PARSE_ERROR: "CONFIG_PARSE_ERROR",
CONFIG_PERMISSION_ERROR: "CONFIG_PERMISSION_ERROR",
INVALID_PRESET: "INVALID_PRESET",
PRESET_NOT_FOUND: "PRESET_NOT_FOUND",
INVALID_LAYOUT: "INVALID_LAYOUT",
INVALID_PANE: "INVALID_PANE",
TMUX_NOT_RUNNING: "TMUX_NOT_RUNNING",
TMUX_COMMAND_FAILED: "TMUX_COMMAND_FAILED",
NOT_IN_TMUX_SESSION: "NOT_IN_TMUX_SESSION",
NOT_IN_TMUX: "NOT_IN_TMUX",
TMUX_NOT_FOUND: "TMUX_NOT_FOUND",
TMUX_NOT_INSTALLED: "TMUX_NOT_INSTALLED",
UNSUPPORTED_TMUX_VERSION: "UNSUPPORTED_TMUX_VERSION",
};
function isVDELayoutError(error) {
return error instanceof VDELayoutError;
}
function formatError(error) {
if (!isVDELayoutError(error)) {
return `${error.name}: ${error.message}`;
}
let message = `Error: ${error.message}\n`;
const formatter = errorFormatters[error.code];
if (formatter) {
message += formatter(error);
}
if (error.details.preset !== undefined) {
message += `\nPreset: ${error.details.preset}\n`;
}
if (error.details.command !== undefined) {
message += `\nCommand: ${error.details.command}\n`;
}
if (error.details.exitCode !== undefined) {
message += `Exit code: ${error.details.exitCode}\n`;
}
if (error.details.stderr !== undefined) {
message += `Error output: ${error.details.stderr}\n`;
}
if (error.details.errors !== undefined && Array.isArray(error.details.errors)) {
message += "\nValidation errors:\n";
error.details.errors.forEach((err) => {
message += ` - ${err}\n`;
});
}
return message;
}
const errorFormatters = {
[exports.ErrorCodes.CONFIG_NOT_FOUND]: (error) => {
let msg = "";
if (error.details.searchPaths !== undefined) {
msg += "\nSearched in the following locations:\n";
const paths = error.details.searchPaths;
paths.forEach((path) => {
msg += ` - ${path}\n`;
});
msg += "\nTo create a configuration file, run:\n";
msg += " mkdir -p ~/.config/vde\n";
msg += ' echo "presets: {}" > ~/.config/vde/layout.yml\n';
}
return msg;
},
[exports.ErrorCodes.NOT_IN_TMUX_SESSION]: () => {
return "\nThis command must be run inside a tmux session.\nStart tmux first with: tmux\n";
},
[exports.ErrorCodes.TMUX_NOT_INSTALLED]: () => {
return ("\ntmux is required but not installed.\n" +
"Install tmux using your package manager:\n" +
" - macOS: brew install tmux\n" +
" - Ubuntu/Debian: sudo apt-get install tmux\n" +
" - Fedora: sudo dnf install tmux\n");
},
[exports.ErrorCodes.UNSUPPORTED_TMUX_VERSION]: (error) => {
let msg = "";
if (error.details.requiredVersion !== undefined) {
msg += `\nRequired tmux version: ${error.details.requiredVersion} or higher\n`;
}
return msg;
},
};
//# sourceMappingURL=errors.js.map