Skip to main content

tibet_cortex_core/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum CortexError {
5    #[error("JIS access denied: required level {required}, got {actual}")]
6    JisAccessDenied { required: u8, actual: u8 },
7
8    #[error("JIS claim expired at {expired_at}")]
9    JisClaimExpired { expired_at: String },
10
11    #[error("JIS claim dimension mismatch: {dimension}")]
12    JisDimensionMismatch { dimension: String },
13
14    #[error("Airlock violation: {0}")]
15    AirlockViolation(String),
16
17    #[error("Airlock already sealed")]
18    AirlockSealed,
19
20    #[error("TIBET integrity check failed: expected {expected}, got {actual}")]
21    TibetIntegrityFailed { expected: String, actual: String },
22
23    #[error("TIBET chain broken at token {token_id}")]
24    TibetChainBroken { token_id: String },
25
26    #[error("Signature verification failed")]
27    SignatureInvalid,
28
29    #[error("Envelope corrupted: {0}")]
30    EnvelopeCorrupted(String),
31
32    #[error("Crypto error: {0}")]
33    Crypto(String),
34
35    #[error("Storage error: {0}")]
36    Storage(String),
37
38    #[error("Serialization error: {0}")]
39    Serialization(#[from] serde_json::Error),
40}
41
42pub type CortexResult<T> = Result<T, CortexError>;