aivcs_core/domain/
error.rs1#[derive(Debug, thiserror::Error)]
5pub enum AivcsError {
6 #[error("invalid agent spec: {0}")]
7 InvalidAgentSpec(String),
8
9 #[error("run not found: {0}")]
10 RunNotFound(uuid::Uuid),
11
12 #[error("eval suite not found: {0}")]
13 EvalSuiteNotFound(uuid::Uuid),
14
15 #[error("release conflict: {0}")]
16 ReleaseConflict(String),
17
18 #[error("digest mismatch: expected {expected}, got {actual}")]
19 DigestMismatch { expected: String, actual: String },
20
21 #[error("git error: {0}")]
22 GitError(String),
23
24 #[error("serialization error: {0}")]
25 Serialization(#[from] serde_json::Error),
26
27 #[error("storage error: {0}")]
28 StorageError(String),
29}
30
31pub type Result<T> = std::result::Result<T, AivcsError>;
33
34#[cfg(test)]
35mod tests {
36 use super::*;
37
38 #[test]
39 fn test_aivcs_error_display() {
40 let err = AivcsError::InvalidAgentSpec("missing git_sha".to_string());
41 assert!(err.to_string().contains("invalid agent spec"));
42
43 let id = uuid::Uuid::new_v4();
44 let err = AivcsError::RunNotFound(id);
45 assert!(err.to_string().contains("run not found"));
46 }
47
48 #[test]
49 fn test_digest_mismatch_error() {
50 let err = AivcsError::DigestMismatch {
51 expected: "abc123".to_string(),
52 actual: "def456".to_string(),
53 };
54 let msg = err.to_string();
55 assert!(msg.contains("abc123"));
56 assert!(msg.contains("def456"));
57 }
58
59 #[test]
60 fn test_storage_error() {
61 let err = AivcsError::StorageError("database connection failed".to_string());
62 assert!(err.to_string().contains("storage error"));
63 assert!(err.to_string().contains("database connection failed"));
64 }
65}