rightkit_browser/
error.rs1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum BrowserError {
5 #[error("no Chrome, Chromium, or Edge executable found")]
6 ChromeNotFound,
7 #[error("launch failed: {0}")]
8 Launch(String),
9 #[error("profile error: {0}")]
10 Profile(String),
11 #[error("profile '{0}' is already in use by another session")]
12 ProfileInUse(String),
13 #[error("cdp error: {0}")]
14 Cdp(String),
15 #[error("stale or foreign ref '{0}'; observe again before acting")]
16 StaleRef(String),
17 #[error("no element matched '{0}'")]
18 NoElement(String),
19 #[error("selector '{0}' is ambiguous ({1} matches)")]
20 Ambiguous(String, u64),
21 #[error("element '{0}' is not visible or has no box")]
22 NotInteractable(String),
23 #[error("unknown page '{0}'")]
24 UnknownPage(String),
25 #[error("unknown key '{0}'")]
26 UnknownKey(String),
27 #[error("timed out: {0}")]
28 Timeout(String),
29 #[error("invalid argument: {0}")]
30 Invalid(String),
31 #[error("denied before effect: {0}")]
33 Denied(String),
34 #[error("blocked by network policy: {0}")]
36 Blocked(crate::policy::PolicyDenial),
37 #[error("io: {0}")]
38 Io(#[from] std::io::Error),
39}
40
41pub type Result<T> = std::result::Result<T, BrowserError>;
42
43pub(crate) fn cdp<E: std::fmt::Display>(e: E) -> BrowserError {
44 BrowserError::Cdp(e.to_string())
45}