synap_sdk/error.rs
1//! Error types for Synap SDK
2
3use thiserror::Error;
4
5/// Result type alias for Synap SDK operations
6pub type Result<T> = std::result::Result<T, SynapError>;
7
8/// Synap SDK error types
9#[derive(Error, Debug)]
10pub enum SynapError {
11 /// HTTP request error
12 #[error("HTTP error: {0}")]
13 HttpError(#[from] reqwest::Error),
14
15 /// JSON serialization/deserialization error
16 #[error("JSON error: {0}")]
17 JsonError(#[from] serde_json::Error),
18
19 /// Invalid URL
20 #[error("Invalid URL: {0}")]
21 InvalidUrl(#[from] url::ParseError),
22
23 /// Server returned an error
24 #[error("Server error: {0}")]
25 ServerError(String),
26
27 /// Key not found
28 #[error("Key not found: {0}")]
29 KeyNotFound(String),
30
31 /// Queue not found
32 #[error("Queue not found: {0}")]
33 QueueNotFound(String),
34
35 /// Stream room not found
36 #[error("Stream room not found: {0}")]
37 RoomNotFound(String),
38
39 /// Invalid response from server
40 #[error("Invalid response: {0}")]
41 InvalidResponse(String),
42
43 /// Operation timeout
44 #[error("Operation timeout")]
45 Timeout,
46
47 /// TCP transport or I/O error
48 #[error("Transport error: {0}")]
49 Transport(String),
50
51 /// Command has no native mapping for the active transport.
52 ///
53 /// Raised when `synap://` or `resp3://` transport is selected and the
54 /// command is not in the native-protocol mapper. Use `http://` transport
55 /// for commands that are not yet mapped, or check the transport mapper.
56 #[error("command '{command}' is not supported on transport '{transport}'")]
57 UnsupportedCommand {
58 /// The SDK command name (e.g. `"pubsub.subscribe"`).
59 command: String,
60 /// The active transport mode (e.g. `"SynapRpc"`, `"Resp3"`).
61 transport: String,
62 },
63
64 /// Generic error
65 #[error("{0}")]
66 Other(String),
67}