1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/// Custom error types for git-worktree-manager.
///
/// Maps directly from the Python exception hierarchy in exceptions.py.
use thiserror::Error;
/// Base error type for all git-worktree-manager errors.
#[derive(Error, Debug)]
pub enum CwError {
/// Raised when a git operation fails.
#[error("{0}")]
Git(String),
/// Raised when a worktree cannot be found.
#[error("{0}")]
WorktreeNotFound(String),
/// Raised when a branch is invalid or in an unexpected state.
#[error("{0}")]
InvalidBranch(String),
/// Raised when a merge operation fails.
#[error("{0}")]
Merge(String),
/// Raised when a rebase operation fails.
#[error("{0}")]
Rebase(String),
/// Raised when a hook execution fails.
#[error("{0}")]
Hook(String),
/// Raised when configuration operations fail.
#[error("{0}")]
Config(String),
/// I/O errors.
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
/// JSON serialization/deserialization errors.
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
/// Generic error with message.
#[error("{0}")]
Other(String),
}
pub type Result<T> = std::result::Result<T, CwError>;