cdp_lite/
error.rs

1use std::time::Duration;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum CdpError {
6    #[error("Network error: {0}")]
7    Network(#[from] reqwest::Error),
8
9    #[error("WebSocket error: {0}")]
10    Ws(#[from] tokio_tungstenite::tungstenite::Error),
11
12    #[error("Serialization error: {0}")]
13    Json(#[from] serde_json::Error),
14
15    #[error("Chrome target not found")]
16    NotFound,
17
18    #[error("Command {method} timed out after {timeout:?}")]
19    Timeout {
20        method: String,
21        timeout: Duration,
22    },
23
24    #[error("No suitable Chrome target found at host: {0}")]
25    NoPageTargetFound(String),
26
27    #[error("Internal communication error: {0}")]
28    InternalError(String),
29
30    #[error("Chrome returned an error (code {code}): {message}")]
31    ProtocolError {
32        code: i64,
33        message: String,
34    },
35
36    #[error("Connection lost")]
37    Disconnected,
38}
39
40pub type CdpResult<T> = Result<T, CdpError>;