Skip to main content

trojan_agent/
error.rs

1//! Agent error types.
2
3use crate::protocol::ErrorCode;
4
5/// Agent error type.
6#[derive(Debug, thiserror::Error)]
7pub enum AgentError {
8    #[error("io: {0}")]
9    Io(#[from] std::io::Error),
10
11    #[error("config: {0}")]
12    Config(String),
13
14    #[error("websocket: {0}")]
15    WebSocket(#[from] tokio_tungstenite::tungstenite::Error),
16
17    #[error("json: {0}")]
18    Json(#[from] serde_json::Error),
19
20    #[error("bincode: {0}")]
21    Bincode(#[from] Box<bincode::ErrorKind>),
22
23    #[error("panel error ({code:?}): {message}")]
24    Panel { code: ErrorCode, message: String },
25
26    #[error("registration failed: {0}")]
27    Registration(String),
28
29    #[error("service error: {0}")]
30    Service(String),
31
32    #[error("cache: {0}")]
33    Cache(String),
34
35    #[error("protocol version mismatch: expected {expected}, got {got}")]
36    ProtocolMismatch { expected: u32, got: u32 },
37
38    #[error("connection closed")]
39    ConnectionClosed,
40}