1pub type Result<T> = std::result::Result<T, Error>;
5
6#[derive(Debug, thiserror::Error)]
8pub enum Error {
9 #[error("WebSocket connection error: {0}")]
11 Connection(String),
12
13 #[error("Failed to send WebSocket message: {0}")]
15 Send(String),
16
17 #[error("Failed to receive WebSocket message: {0}")]
19 Receive(String),
20
21 #[error("Protocol error: {0}")]
23 Protocol(String),
24
25 #[error("Serialization error: {0}")]
27 Serialization(String),
28
29 #[error("Deserialization error: {0}")]
31 Deserialization(String),
32
33 #[error("Compression error: {0}")]
35 Compression(String),
36
37 #[error("Decompression error: {0}")]
39 Decompression(String),
40
41 #[error("Subscription error: {0}")]
43 Subscription(String),
44
45 #[error("Authentication failed: {0}")]
47 Authentication(String),
48
49 #[error("Authorization failed: {0}")]
51 Authorization(String),
52
53 #[error("Rate limit exceeded: {0}")]
55 RateLimit(String),
56
57 #[error("Invalid message: {0}")]
59 InvalidMessage(String),
60
61 #[error("Invalid parameter: {0}")]
63 InvalidParameter(String),
64
65 #[error("Resource not found: {0}")]
67 NotFound(String),
68
69 #[error("Server error: {0}")]
71 Server(String),
72
73 #[error("Client error: {0}")]
75 Client(String),
76
77 #[error("Operation timed out: {0}")]
79 Timeout(String),
80
81 #[error("Channel send error")]
83 ChannelSend,
84
85 #[error("Channel receive error")]
87 ChannelReceive,
88
89 #[error("IO error: {0}")]
91 Io(#[from] std::io::Error),
92
93 #[error("OxiGDAL error: {0}")]
95 Core(String),
96
97 #[error("JSON error: {0}")]
99 Json(#[from] serde_json::Error),
100
101 #[error("MessagePack error: {0}")]
103 MessagePack(String),
104
105 #[error("Axum error: {0}")]
107 Axum(String),
108
109 #[error("Other error: {0}")]
111 Other(String),
112}
113
114impl From<axum::Error> for Error {
115 fn from(err: axum::Error) -> Self {
116 Error::Axum(err.to_string())
117 }
118}
119
120impl From<rmp_serde::encode::Error> for Error {
121 fn from(err: rmp_serde::encode::Error) -> Self {
122 Error::MessagePack(err.to_string())
123 }
124}
125
126impl From<rmp_serde::decode::Error> for Error {
127 fn from(err: rmp_serde::decode::Error) -> Self {
128 Error::MessagePack(err.to_string())
129 }
130}
131
132impl<T> From<tokio::sync::mpsc::error::SendError<T>> for Error {
133 fn from(_: tokio::sync::mpsc::error::SendError<T>) -> Self {
134 Error::ChannelSend
135 }
136}
137
138impl From<tokio::sync::oneshot::error::RecvError> for Error {
139 fn from(_: tokio::sync::oneshot::error::RecvError) -> Self {
140 Error::ChannelReceive
141 }
142}