1use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum GitError {
7 #[error("Not a git repository (or any of the parent directories)")]
8 NotAGitRepository,
9
10 #[error("Git command failed ({command}): {message}")]
11 CommandFailed { command: String, message: String },
12
13 #[error("Failed to execute git process: {0}")]
14 ProcessFailed(#[from] std::io::Error),
15}
16
17#[derive(Error, Debug, PartialEq, Eq)]
18pub enum LockError {
19 #[error("Timed out waiting to acquire advisory lock at '{path}' after {timeout_secs}s")]
20 Timeout { path: String, timeout_secs: u64 },
21
22 #[error("Failed to open or create lock file at '{path}': {message}")]
23 IoError { path: String, message: String },
24}
25
26#[derive(Error, Debug)]
27pub enum RegistryError {
28 #[error("Failed to read registry at '{path}': {source}")]
29 IoError {
30 path: String,
31 #[source]
32 source: std::io::Error,
33 },
34
35 #[error("Failed to parse registry JSON at '{path}': {source}")]
36 JsonError {
37 path: String,
38 #[source]
39 source: serde_json::Error,
40 },
41}
42
43#[derive(Error, Debug)]
44pub enum WorktreeError {
45 #[error("Failed to create worktree at '{path}': {message}")]
46 CreationFailed { path: String, message: String },
47
48 #[error("Failed to remove worktree at '{path}': {message}")]
49 RemovalFailed { path: String, message: String },
50
51 #[error("Branch already exists: '{0}'")]
52 BranchAlreadyExists(String),
53
54 #[error("Worktree directory already exists: '{0}'")]
55 DirectoryAlreadyExists(String),
56
57 #[error("I/O error during worktree operation: {0}")]
58 IoError(#[from] std::io::Error),
59}
60
61#[derive(Error, Debug)]
62pub enum HookError {
63 #[error("Hook execution failed: {0}")]
64 ExecutionFailed(String),
65
66 #[error(
67 "Pre-finish hook '{hook}' failed with exit code {code}; aborting (use --force to override)"
68 )]
69 PreFinishFailed { hook: String, code: i32 },
70}