1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, CommyError>;
7
8#[derive(Error, Debug)]
10pub enum CommyError {
11 #[error("WebSocket error: {0}")]
13 WebSocketError(String),
14
15 #[error("Connection lost: {0}")]
17 ConnectionLost(String),
18
19 #[error("Authentication failed: {0}")]
21 AuthenticationFailed(String),
22
23 #[error("Unauthorized: {0}")]
25 Unauthorized(String),
26
27 #[error("Not found: {0}")]
29 NotFound(String),
30
31 #[error("Service not found: {0}")]
33 ServiceNotFound(String),
34
35 #[error("Tenant not found: {0}")]
37 TenantNotFound(String),
38
39 #[error("Already exists: {0}")]
41 AlreadyExists(String),
42
43 #[error("Permission denied: {0}")]
45 PermissionDenied(String),
46
47 #[error("Invalid request: {0}")]
49 InvalidRequest(String),
50
51 #[error("Invalid message format: {0}")]
53 InvalidMessage(String),
54
55 #[error("Serialization error: {0}")]
57 SerializationError(#[from] serde_json::Error),
58
59 #[error("MessagePack error: {0}")]
61 MessagePackError(#[from] rmp_serde::encode::Error),
62
63 #[error("MessagePack decode error: {0}")]
65 MessagePackDecodeError(#[from] rmp_serde::decode::Error),
66
67 #[error("Operation timeout")]
69 Timeout,
70
71 #[error("Channel error: {0}")]
73 ChannelError(String),
74
75 #[error("Invalid state: {0}")]
77 InvalidState(String),
78
79 #[error("Memory mapping error: {0}")]
81 MemoryMappingError(String),
82
83 #[error("File I/O error: {0}")]
85 FileError(#[from] std::io::Error),
86
87 #[error("File watcher error: {0}")]
89 WatcherError(String),
90
91 #[error("Variable not found: {0}")]
93 VariableNotFound(String),
94
95 #[error("Invalid variable offset: {0}")]
97 InvalidOffset(String),
98
99 #[error("SIMD operation error: {0}")]
101 SimdError(String),
102
103 #[error("{0}")]
105 Other(String),
106}
107
108impl From<tokio_tungstenite::tungstenite::Error> for CommyError {
109 fn from(err: tokio_tungstenite::tungstenite::Error) -> Self {
110 CommyError::WebSocketError(err.to_string())
111 }
112}