1use crate::io::ParseError;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
7pub enum Error {
8 #[error("JSON serialization error: {0}")]
9 Json(#[from] serde_json::Error),
10
11 #[error("IO error: {0}")]
12 Io(#[from] std::io::Error),
13
14 #[error("Protocol error: {0}")]
15 Protocol(String),
16
17 #[error("Invalid message type: {0}")]
18 InvalidMessageType(String),
19
20 #[error("Missing required field: {0}")]
21 MissingField(String),
22
23 #[error("Invalid state transition: {0}")]
24 InvalidState(String),
25
26 #[error("Timeout occurred")]
27 Timeout,
28
29 #[error("Connection closed")]
30 ConnectionClosed,
31
32 #[error("Deserialization error: {0}")]
33 Deserialization(#[from] ParseError),
34
35 #[error("Session UUID not yet available - no response received")]
36 SessionNotInitialized,
37
38 #[error("Unknown error: {0}")]
39 Unknown(String),
40}
41
42pub type Result<T> = std::result::Result<T, Error>;