use thiserror::Error;
use crate::types::SnapshotId;
#[derive(Debug, Error)]
pub enum VcsError {
#[error("snapshot already exists: {0}")]
SnapshotAlreadyExists(SnapshotId),
#[error("snapshot not found: {0}")]
SnapshotNotFound(SnapshotId),
#[error("branch not found: {namespace}/{name}")]
BranchNotFound { namespace: String, name: String },
#[error("non-fast-forward: local={local_head}, remote={remote_head}")]
NonFastForward {
local_head: SnapshotId,
remote_head: SnapshotId,
},
#[error("remote unreachable: {url} — {cause}")]
RemoteUnreachable { url: String, cause: String },
#[error("authentication failed for remote: {url}")]
AuthFailed { url: String },
#[error("hash mismatch: expected {expected}, actual {actual}")]
HashMismatch {
expected: SnapshotId,
actual: SnapshotId,
},
#[error("merge required: remote history has diverged from local")]
MergeRequired,
#[error("uncommitted changes: {count} entities/edges modified since last commit")]
UncommittedChanges { count: usize },
#[error("merge not implemented: link khive-merge to enable three-way merge")]
MergeNotImplemented,
#[error("invalid snapshot id: {0}")]
InvalidSnapshotId(String),
#[error("invalid branch name: {0:?}")]
InvalidBranchName(String),
#[error("storage: {0}")]
Storage(String),
#[error("json: {0}")]
Json(#[from] serde_json::Error),
#[error("io: {0}")]
Io(#[from] std::io::Error),
#[error("internal: {0}")]
Internal(String),
}
impl From<khive_runtime::error::RuntimeError> for VcsError {
fn from(e: khive_runtime::error::RuntimeError) -> Self {
VcsError::Storage(e.to_string())
}
}