1use thiserror::Error;
6
7use crate::types::SnapshotId;
8
9#[derive(Debug, Error)]
10pub enum VcsError {
11 #[error("snapshot already exists: {0}")]
15 SnapshotAlreadyExists(SnapshotId),
16
17 #[error("snapshot not found: {0}")]
20 SnapshotNotFound(SnapshotId),
21
22 #[error("branch not found: {namespace}/{name}")]
24 BranchNotFound { namespace: String, name: String },
25
26 #[error("non-fast-forward: local={local_head}, remote={remote_head}")]
29 NonFastForward {
30 local_head: SnapshotId,
31 remote_head: SnapshotId,
32 },
33
34 #[error("remote unreachable: {url} — {cause}")]
36 RemoteUnreachable { url: String, cause: String },
37
38 #[error("authentication failed for remote: {url}")]
40 AuthFailed { url: String },
41
42 #[error("hash mismatch: expected {expected}, actual {actual}")]
45 HashMismatch {
46 expected: SnapshotId,
47 actual: SnapshotId,
48 },
49
50 #[error("merge required: remote history has diverged from local")]
52 MergeRequired,
53
54 #[error("uncommitted changes: {count} entities/edges modified since last commit")]
57 UncommittedChanges { count: usize },
58
59 #[error("merge not implemented: link khive-merge to enable three-way merge")]
62 MergeNotImplemented,
63
64 #[error("invalid snapshot id: {0}")]
66 InvalidSnapshotId(String),
67
68 #[error("storage: {0}")]
70 Storage(String),
71
72 #[error("json: {0}")]
74 Json(#[from] serde_json::Error),
75
76 #[error("io: {0}")]
78 Io(#[from] std::io::Error),
79
80 #[error("internal: {0}")]
82 Internal(String),
83}
84
85impl From<khive_runtime::error::RuntimeError> for VcsError {
86 fn from(e: khive_runtime::error::RuntimeError) -> Self {
87 VcsError::Storage(e.to_string())
88 }
89}