Skip to main content

oxigdal_sync/
error.rs

1//! Error types for synchronization operations
2
3use thiserror::Error;
4
5/// Result type for synchronization operations
6pub type SyncResult<T> = Result<T, SyncError>;
7
8/// Synchronization error types
9#[derive(Error, Debug)]
10pub enum SyncError {
11    /// Vector clock comparison resulted in concurrent/conflicting events
12    #[error("Concurrent events detected: {0}")]
13    ConcurrentEvents(String),
14
15    /// Invalid operation in operational transformation
16    #[error("Invalid operation: {0}")]
17    InvalidOperation(String),
18
19    /// Merkle tree verification failed
20    #[error("Merkle tree verification failed: {0}")]
21    MerkleVerificationFailed(String),
22
23    /// Delta encoding/decoding error
24    #[error("Delta encoding error: {0}")]
25    DeltaEncodingError(String),
26
27    /// Device coordination error
28    #[error("Device coordination error: {0}")]
29    CoordinationError(String),
30
31    /// CRDT merge conflict
32    #[error("CRDT merge conflict: {0}")]
33    MergeConflict(String),
34
35    /// Serialization error
36    #[error("Serialization error: {0}")]
37    SerializationError(String),
38
39    /// I/O error
40    #[error("I/O error: {0}")]
41    IoError(#[from] std::io::Error),
42
43    /// JSON error
44    #[error("JSON error: {0}")]
45    JsonError(#[from] serde_json::Error),
46
47    /// Invalid device ID
48    #[error("Invalid device ID: {0}")]
49    InvalidDeviceId(String),
50
51    /// Operation timeout
52    #[error("Operation timeout: {0}")]
53    Timeout(String),
54
55    /// Network error
56    #[error("Network error: {0}")]
57    NetworkError(String),
58
59    /// State inconsistency detected
60    #[error("State inconsistency: {0}")]
61    StateInconsistency(String),
62}