clasp_federation/
error.rs1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum FederationError {
8 #[error("connection to peer failed: {0}")]
10 ConnectionFailed(String),
11
12 #[error("federation handshake failed: {0}")]
14 HandshakeFailed(String),
15
16 #[error("namespace conflict: {pattern} claimed by both {a} and {b}")]
18 NamespaceConflict {
19 pattern: String,
20 a: String,
21 b: String,
22 },
23
24 #[error("peer not found: {0}")]
26 PeerNotFound(String),
27
28 #[error("transport error: {0}")]
30 Transport(String),
31
32 #[error("codec error: {0}")]
34 Codec(String),
35
36 #[error("sync error: {0}")]
38 Sync(String),
39
40 #[error("already connected to peer: {0}")]
42 AlreadyConnected(String),
43
44 #[error("configuration error: {0}")]
46 Config(String),
47}
48
49pub type Result<T> = std::result::Result<T, FederationError>;
51
52impl From<clasp_core::Error> for FederationError {
53 fn from(e: clasp_core::Error) -> Self {
54 FederationError::Codec(e.to_string())
55 }
56}
57
58impl From<clasp_transport::TransportError> for FederationError {
59 fn from(e: clasp_transport::TransportError) -> Self {
60 FederationError::Transport(e.to_string())
61 }
62}