ralph_workflow/checkpoint/file_state/
error.rs1use crate::common::domain_types::GitOid;
2
3#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
5pub enum ValidationError {
6 FileMissing { path: String },
8
9 FileUnexpectedlyExists { path: String },
11
12 FileContentChanged { path: String },
14
15 GitHeadChanged { expected: GitOid, actual: GitOid },
17
18 GitWorkingTreeChanged { changes: String },
20
21 GitStateInvalid { reason: String },
23}
24
25impl std::fmt::Display for ValidationError {
26 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27 match self {
28 Self::FileMissing { path } => write!(f, "File missing: {path}"),
29 Self::FileUnexpectedlyExists { path } => write!(f, "File unexpectedly exists: {path}"),
30 Self::FileContentChanged { path } => write!(f, "File content changed: {path}"),
31 Self::GitHeadChanged { expected, actual } => {
32 write!(f, "Git HEAD changed: expected {expected}, got {actual}")
33 }
34 Self::GitWorkingTreeChanged { changes } => {
35 write!(f, "Git working tree changed: {changes}")
36 }
37 Self::GitStateInvalid { reason } => write!(f, "Git state invalid: {reason}"),
38 }
39 }
40}
41
42impl std::error::Error for ValidationError {}