Skip to main content

nodedb_crdt/
error.rs

1//! Error types for the CRDT engine.
2
3/// Errors produced by CRDT operations.
4#[derive(Debug, thiserror::Error)]
5pub enum CrdtError {
6    /// A constraint was violated during validation.
7    #[error("constraint violation: {constraint} on collection `{collection}`: {detail}")]
8    ConstraintViolation {
9        constraint: String,
10        collection: String,
11        detail: String,
12    },
13
14    /// The delta could not be applied to the current state.
15    #[error("delta application failed: {0}")]
16    DeltaApplyFailed(String),
17
18    /// Loro internal error.
19    #[error("loro error: {0}")]
20    Loro(String),
21
22    /// Dead-letter queue is full.
23    #[error("dead-letter queue full: capacity {capacity}, pending {pending}")]
24    DlqFull { capacity: usize, pending: usize },
25
26    /// The collection does not exist.
27    #[error("unknown collection: {0}")]
28    UnknownCollection(String),
29
30    /// Auth context has expired — agent must re-authenticate before syncing.
31    #[error("auth expired: user {user_id} must re-authenticate (expired at {expired_at})")]
32    AuthExpired { user_id: u64, expired_at: u64 },
33
34    /// Delta signature verification failed.
35    #[error("delta signature invalid for user {user_id}: {detail}")]
36    InvalidSignature { user_id: u64, detail: String },
37}
38
39pub type Result<T> = std::result::Result<T, CrdtError>;