Skip to main content

spacedb_crdt/
error.rs

1//! Errors for the convergent-document layer.
2
3use thiserror::Error;
4
5/// Result alias for `spacedb-crdt`.
6pub type CrdtResult<T> = Result<T, CrdtError>;
7
8#[derive(Debug, Error)]
9pub enum CrdtError {
10    /// A remote update could not be decoded (corrupt or wrong wire version).
11    #[error("decode update: {0}")]
12    DecodeUpdate(String),
13
14    /// A decoded update failed to apply.
15    #[error("apply update: {0}")]
16    ApplyUpdate(String),
17
18    /// A peer's state vector could not be decoded.
19    #[error("decode state vector: {0}")]
20    DecodeStateVector(String),
21
22    /// A register value failed to (de)serialize through JSON.
23    #[error("value codec for field `{field}`: {source}")]
24    ValueCodec {
25        field: String,
26        source: serde_json::Error,
27    },
28
29    /// An underlying storage error from the persistence layer (S2): the encrypted
30    /// `spacedb-store` engine, codec, or AEAD boundary.
31    #[error("store: {0}")]
32    Store(#[from] spacedb_store::StoreError),
33}