Skip to main content

libbrat_worktree/
error.rs

1//! Error types for worktree operations.
2
3use thiserror::Error;
4
5/// Error type for worktree operations.
6#[derive(Debug, Error)]
7pub enum WorktreeError {
8    /// Git command failed.
9    #[error("git command failed: {0}")]
10    GitFailed(String),
11
12    /// Worktree not found.
13    #[error("worktree not found: {0}")]
14    NotFound(String),
15
16    /// Worktree already exists.
17    #[error("worktree already exists: {0}")]
18    AlreadyExists(String),
19
20    /// Maximum number of worktrees reached.
21    #[error("max worktrees reached: {current}/{max}")]
22    MaxReached {
23        /// Current number of worktrees.
24        current: u32,
25        /// Maximum allowed.
26        max: u32,
27    },
28
29    /// Invalid worktree path.
30    #[error("invalid worktree path: {0}")]
31    InvalidPath(String),
32
33    /// Invalid session ID.
34    #[error("invalid session id: {0}")]
35    InvalidSessionId(String),
36
37    /// IO error.
38    #[error("io error: {0}")]
39    Io(#[from] std::io::Error),
40}