1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Error types for rpage
use thiserror::Error;
/// Unified error type for all rpage operations
#[derive(Error, Debug)]
pub enum Error {
/// Browser launch or CDP connection failure
#[error("Browser error: {0}")]
Browser(String),
/// Network / HTTP request failure
#[error("Network error: {0}")]
Network(String),
/// Element not found on the page
#[error("Element not found: {0}")]
ElementNotFound(String),
/// Invalid locator string
#[error("Invalid locator: {0}")]
InvalidLocator(String),
/// Operation timed out
#[error("Timeout: {0}")]
Timeout(String),
/// Cookie synchronization failure
#[error("Cookie sync error: {0}")]
CookieSync(String),
/// Configuration error
#[error("Config error: {0}")]
Config(String),
/// I/O error
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
/// reqwest HTTP error
#[error("HTTP error: {0}")]
Reqwest(#[from] reqwest::Error),
/// URL parsing error
#[error("URL error: {0}")]
Url(#[from] url::ParseError),
/// JSON serialization / deserialization error
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
/// CDP error from chromiumoxide
#[error("CDP error: {0}")]
Cdp(String),
/// Generic error from anyhow
#[error("{0}")]
Other(#[from] anyhow::Error),
}
/// Convenience result alias
pub type Result<T> = std::result::Result<T, Error>;
impl From<chromiumoxide::error::CdpError> for Error {
fn from(e: chromiumoxide::error::CdpError) -> Self {
Error::Cdp(e.to_string())
}
}