use crate::common::domain_types::GitOid;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum ValidationError {
FileMissing { path: String },
FileUnexpectedlyExists { path: String },
FileContentChanged { path: String },
GitHeadChanged { expected: GitOid, actual: GitOid },
GitWorkingTreeChanged { changes: String },
GitStateInvalid { reason: String },
}
impl std::fmt::Display for ValidationError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::FileMissing { path } => write!(f, "File missing: {path}"),
Self::FileUnexpectedlyExists { path } => write!(f, "File unexpectedly exists: {path}"),
Self::FileContentChanged { path } => write!(f, "File content changed: {path}"),
Self::GitHeadChanged { expected, actual } => {
write!(f, "Git HEAD changed: expected {expected}, got {actual}")
}
Self::GitWorkingTreeChanged { changes } => {
write!(f, "Git working tree changed: {changes}")
}
Self::GitStateInvalid { reason } => write!(f, "Git state invalid: {reason}"),
}
}
}
impl std::error::Error for ValidationError {}