Skip to main content

playhard_cdp/
error.rs

1use thiserror::Error;
2
3/// Result alias for this crate.
4pub type Result<T> = std::result::Result<T, CdpError>;
5
6/// Errors produced by the typed CDP layer.
7#[derive(Debug, Error)]
8pub enum CdpError {
9    /// The protocol returned an error response.
10    #[error("cdp command `{method}` failed: {message}")]
11    Command {
12        /// Command name.
13        method: String,
14        /// Protocol message.
15        message: String,
16    },
17    /// JSON serialization or deserialization failed.
18    #[error("json error: {0}")]
19    Json(#[from] serde_json::Error),
20    /// The transport was not able to execute the request.
21    #[error("transport error: {0}")]
22    Transport(String),
23    /// The protocol response did not match the expected shape.
24    #[error("invalid protocol response: {0}")]
25    InvalidResponse(String),
26}