caudal_sdk/
error.rs

1use std::fmt;
2
3/// Caudal SDK Errors
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum CaudalError {
6    /// Invalid Node ID (empty or incorrect format)
7    InvalidNodeId(String),
8    /// Emission buffer full
9    BufferFull,
10    /// Transport error
11    TransportError(String),
12    /// Serialization error
13    SerializationError(String),
14    /// Validation error
15    ValidationError(String),
16}
17
18impl fmt::Display for CaudalError {
19    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20        match self {
21            CaudalError::InvalidNodeId(msg) => write!(f, "Invalid node ID: {}", msg),
22            CaudalError::BufferFull => write!(f, "Event buffer is full"),
23            CaudalError::TransportError(msg) => write!(f, "Transport error: {}", msg),
24            CaudalError::SerializationError(msg) => write!(f, "Serialization error: {}", msg),
25            CaudalError::ValidationError(msg) => write!(f, "Validation error: {}", msg),
26        }
27    }
28}
29
30impl std::error::Error for CaudalError {}
31
32/// Result type for the Caudal SDK
33pub type Result<T> = std::result::Result<T, CaudalError>;