use std::fmt;
#[derive(Debug)]
pub enum SdkError {
DocumentNotFound(String),
PeerNotFound(String),
ConnectionFailed(String),
SyncError(String),
NetworkError(String),
SerializationError(String),
Internal(String),
}
impl fmt::Display for SdkError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
SdkError::DocumentNotFound(id) => write!(f, "Document not found: {}", id),
SdkError::PeerNotFound(id) => write!(f, "Peer not found: {}", id),
SdkError::ConnectionFailed(e) => write!(f, "Connection failed: {}", e),
SdkError::SyncError(e) => write!(f, "Sync error: {}", e),
SdkError::NetworkError(e) => write!(f, "Network error: {}", e),
SdkError::SerializationError(e) => write!(f, "Serialization error: {}", e),
SdkError::Internal(e) => write!(f, "Internal error: {}", e),
}
}
}
impl std::error::Error for SdkError {}
pub type Result<T> = std::result::Result<T, SdkError>;