1use std::path::PathBuf;
4
5pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Debug, thiserror::Error)]
10pub enum Error {
11 #[error("not a git repository (or any parent up to mount point)")]
13 NotARepository,
14
15 #[error("rung not initialized in this repository - run `rung init` first")]
17 NotInitialized,
18
19 #[error("branch not found: {0}")]
21 BranchNotFound(String),
22
23 #[error("invalid branch name '{name}': {reason}")]
25 InvalidBranchName {
26 name: String,
28 reason: String,
30 },
31
32 #[error("branch '{0}' is not part of a rung stack")]
34 NotInStack(String),
35
36 #[error("cyclic dependency detected: {0}")]
38 CyclicDependency(String),
39
40 #[error("parent branch '{parent}' for '{branch}' no longer exists")]
42 OrphanedBranch { branch: String, parent: String },
43
44 #[error("conflict in {file} while syncing {branch}")]
46 ConflictDetected { branch: String, file: String },
47
48 #[error("rebase failed for branch '{0}': {1}")]
50 RebaseFailed(String, String),
51
52 #[error("no backup found - nothing to undo")]
54 NoBackupFound,
55
56 #[error("sync already in progress - run `rung sync --continue` or `rung sync --abort`")]
58 SyncInProgress,
59
60 #[error("sync failed: {0}")]
62 SyncFailed(String),
63
64 #[error("failed to parse {file}: {message}")]
66 StateParseError { file: PathBuf, message: String },
67
68 #[error("io error: {0}")]
70 Io(#[from] std::io::Error),
71
72 #[error("json error: {0}")]
74 Json(#[from] serde_json::Error),
75
76 #[error("toml error: {0}")]
78 Toml(#[from] toml::de::Error),
79
80 #[error("git error: {0}")]
82 Git(#[from] rung_git::Error),
83
84 #[error("absorb error: {0}")]
86 Absorb(String),
87}