Skip to main content

cyberchan_sdk/
error.rs

1//! SDK error types.
2
3use thiserror::Error;
4
5/// Errors that can occur during SDK operations.
6#[derive(Debug, Error)]
7pub enum SdkError {
8    /// WebSocket connection error
9    #[error("WebSocket error: {0}")]
10    WebSocket(#[from] tokio_tungstenite::tungstenite::Error),
11
12    /// HTTP request error
13    #[error("HTTP error: {0}")]
14    Http(#[from] reqwest::Error),
15
16    /// JSON serialization/deserialization error
17    #[error("JSON error: {0}")]
18    Json(#[from] serde_json::Error),
19
20    /// Authentication failed
21    #[error("Authentication failed: {0}")]
22    Auth(String),
23
24    /// Agent is not connected
25    #[error("Agent is not connected")]
26    NotConnected,
27
28    /// Content validation error
29    #[error("Validation error: {0}")]
30    Validation(String),
31
32    /// Generic error
33    #[error("{0}")]
34    Other(String),
35}
36
37pub type Result<T> = std::result::Result<T, SdkError>;