UNPKG

worktree-tool

Version:

A command-line tool for managing Git worktrees with integrated tmux/shell session management

105 lines 2.77 kB
/** * Custom error classes for wtt */ /** * Base error class for all wtt errors */ export class WorktreeError extends Error { code; details; constructor(message, code, details) { super(message); this.code = code; this.details = details; this.name = "WorktreeError"; // Maintains proper stack trace for where error was thrown Error.captureStackTrace(this, WorktreeError); } } /** * Error thrown when git operations fail */ export class GitError extends WorktreeError { constructor(message, details) { super(message, "GIT_ERROR", details); this.name = "GitError"; } } /** * Error thrown when tmux operations fail */ export class TmuxError extends WorktreeError { constructor(message, details) { super(message, "TMUX_ERROR", details); this.name = "TmuxError"; } } /** * Error thrown when configuration is invalid or missing */ export class ConfigError extends WorktreeError { constructor(message, details) { super(message, "CONFIG_ERROR", details); this.name = "ConfigError"; } } /** * Error thrown when file system operations fail */ export class FileSystemError extends WorktreeError { constructor(message, details) { super(message, "FS_ERROR", details); this.name = "FileSystemError"; } } /** * Error thrown when command validation fails */ export class ValidationError extends WorktreeError { constructor(message, details) { super(message, "VALIDATION_ERROR", details); this.name = "ValidationError"; } } /** * Error thrown when platform operations fail */ export class PlatformError extends WorktreeError { constructor(message, details) { super(message, "PLATFORM_ERROR", details); this.name = "PlatformError"; } } /** * Helper to determine if an error is a WorktreeError */ export function isWorktreeError(error) { return error instanceof WorktreeError; } /** * Helper to format error messages for user display * @deprecated Use getErrorMessage from utils/error-handler.ts instead */ export function formatErrorMessage(error) { console.warn("formatErrorMessage is deprecated. Use getErrorMessage from utils/error-handler.ts instead."); if (isWorktreeError(error)) { return error.message; } if (error instanceof Error) { return error.message; } return String(error); } /** * Error with optional hint for user */ export class WorktreeToolError extends Error { hint; constructor(message, hint) { super(message); this.hint = hint; this.name = "WorktreeToolError"; Error.captureStackTrace(this, WorktreeToolError); } } //# sourceMappingURL=errors.js.map