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
57impl From<serde_json::Error> for CadiError {
58    fn from(e: serde_json::Error) -> Self {
59        CadiError::Serialization(e.to_string())
60    }
61}
62
63/// Result type for CADI operations
64pub type CadiResult<T> = Result<T, CadiError>;