cadi_core/
error.rs

1//! Error types for CADI
2
3use thiserror::Error;
4
5/// Main error type for CADI operations
6#[derive(Error, Debug)]
7pub enum CadiError {
8    #[error("Chunk not found: {0}")]
9    ChunkNotFound(String),
10
11    #[error("Manifest not found: {0}")]
12    ManifestNotFound(String),
13
14    #[error("Invalid chunk ID: {0}")]
15    InvalidChunkId(String),
16
17    #[error("Hash mismatch: expected {expected}, got {actual}")]
18    HashMismatch {
19        expected: String,
20        actual: String,
21    },
22
23    #[error("Build failed: {0}")]
24    BuildFailed(String),
25
26    #[error("Transformation failed: {0}")]
27    TransformFailed(String),
28
29    #[error("Registry error: {0}")]
30    RegistryError(String),
31
32    #[error("IO error: {0}")]
33    Io(#[from] std::io::Error),
34
35    #[error("Serialization error: {0}")]
36    Serialization(String),
37
38    #[error("Verification failed: {0}")]
39    VerificationFailed(String),
40
41    #[error("Signature invalid: {0}")]
42    SignatureInvalid(String),
43
44    #[error("Trust policy violation: {0}")]
45    TrustPolicyViolation(String),
46
47    #[error("Dependency resolution failed: {0}")]
48    DependencyResolution(String),
49
50    #[error("Unsupported platform: {0}")]
51    UnsupportedPlatform(String),
52
53    #[error("Configuration error: {0}")]
54    Configuration(String),
55
56    #[error("Storage error: {0}")]
57    StorageError(String),
58
59    #[error("Graph query error: {0}")]
60    GraphQueryError(String),
61
62    #[error("Atomizer error: {0}")]
63    AtomizerError(String),
64
65    #[error("Rehydration error: {0}")]
66    RehydrationError(String),
67}
68
69impl From<serde_json::Error> for CadiError {
70    fn from(e: serde_json::Error) -> Self {
71        CadiError::Serialization(e.to_string())
72    }
73}
74
75#[cfg(feature = "ast-parsing")]
76impl From<tree_sitter::LanguageError> for CadiError {
77    fn from(e: tree_sitter::LanguageError) -> Self {
78        CadiError::AtomizerError(e.to_string())
79    }
80}
81
82#[cfg(feature = "ast-parsing")]
83impl From<tree_sitter::QueryError> for CadiError {
84    fn from(e: tree_sitter::QueryError) -> Self {
85        CadiError::AtomizerError(e.to_string())
86    }
87}
88
89/// Result type for CADI operations
90pub type CadiResult<T> = Result<T, CadiError>;