atproto blogging
1//! Error types for CRDT operations.
2
3use thiserror::Error;
4
5/// Errors that can occur during CRDT operations.
6#[derive(Error, Debug)]
7#[non_exhaustive]
8pub enum CrdtError {
9 /// Failed to import CRDT data.
10 #[error("failed to import CRDT data: {0}")]
11 Import(String),
12
13 /// Failed to export CRDT data.
14 #[error("failed to export CRDT data: {0}")]
15 Export(String),
16
17 /// Sync operation failed.
18 #[error("sync failed: {0}")]
19 Sync(String),
20
21 /// Not authenticated.
22 #[error("not authenticated")]
23 NotAuthenticated,
24
25 /// Invalid AT-URI.
26 #[error("invalid AT-URI: {0}")]
27 InvalidUri(String),
28
29 /// XRPC call failed.
30 #[error("XRPC error: {0}")]
31 Xrpc(String),
32
33 /// Serialization error.
34 #[error("serialization error: {0}")]
35 Serialization(String),
36
37 /// Loro CRDT error.
38 #[error("loro error: {0}")]
39 Loro(String),
40}
41
42impl From<loro::LoroError> for CrdtError {
43 fn from(e: loro::LoroError) -> Self {
44 CrdtError::Import(e.to_string())
45 }
46}
47
48impl From<jacquard::client::AgentError> for CrdtError {
49 fn from(e: jacquard::client::AgentError) -> Self {
50 CrdtError::Xrpc(e.to_string())
51 }
52}