1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, GwError>;
7
8#[derive(Error, Debug)]
10pub enum GwError {
11 #[error("Not in a git repository")]
12 NotAGitRepository,
13
14 #[error("Git command failed: {0}")]
15 GitCommandFailed(String),
16
17 #[error("Branch '{0}' already exists")]
18 BranchAlreadyExists(String),
19
20 #[error("Branch '{0}' does not exist")]
21 BranchNotFound(String),
22
23 #[error("Cannot delete protected branch: {0}")]
24 ProtectedBranch(String),
25
26 #[error("Uncommitted changes detected. Commit or stash them first.")]
27 UncommittedChanges,
28
29 #[error("Branch '{0}' has {1} unpushed commit(s)")]
30 UnpushedCommits(String, usize),
31
32 #[error("Already on home branch '{0}'. Specify a branch to delete.")]
33 AlreadyOnHomeBranch(String),
34
35 #[error("Branch name is required")]
36 BranchNameRequired,
37
38 #[error("IO error: {0}")]
39 Io(#[from] std::io::Error),
40
41 #[error("Cannot undo: no commits to undo (initial commit or empty history)")]
42 NothingToUndo,
43
44 #[error("{0}")]
45 Other(String),
46}