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("Chrome for Testing not found: {0}")]
10 ChromeForTestingNotFound(String),
11 #[error(
17 "Chrome's sandbox cannot read the browser in {}: no read and execute access for {}. Grant it with: {fix}",
18 .directory.display(),
19 .principals.join(" and ")
20 )]
21 ChromeSandboxAccess {
22 directory: std::path::PathBuf,
23 principals: Vec<&'static str>,
24 fix: String,
25 },
26 #[error("launch failed: {0}")]
27 Launch(String),
28 #[error("profile error: {0}")]
29 Profile(String),
30 #[error("profile '{0}' is already in use by another session")]
31 ProfileInUse(String),
32 #[error("cdp error: {0}")]
33 Cdp(String),
34 #[error("stale or foreign ref '{0}'; observe again before acting")]
35 StaleRef(String),
36 #[error("action loop stopped: {0}")]
39 ActionLoop(String),
40 #[error("no element matched '{0}'")]
41 NoElement(String),
42 #[error("selector '{0}' is ambiguous ({1} matches)")]
43 Ambiguous(String, u64),
44 #[error("element '{0}' is not visible or has no box")]
45 NotInteractable(String),
46 #[error("unknown page '{0}'")]
47 UnknownPage(String),
48 #[error("unknown key '{0}'")]
49 UnknownKey(String),
50 #[error("timed out: {0}")]
51 Timeout(String),
52 #[error("invalid argument: {0}")]
53 Invalid(String),
54 #[error("denied before effect: {0}")]
56 Denied(String),
57 #[error("blocked by network policy: {0}")]
59 Blocked(crate::policy::PolicyDenial),
60 #[error("consent: {0}")]
62 Consent(String),
63 #[error("unsupported: {0}")]
65 Unsupported(String),
66 #[cfg(feature = "profile-vault")]
69 #[error("profile vault: {0}")]
70 Vault(#[from] crate::vault::VaultError),
71 #[error("browser did not stop cleanly: {0}")]
73 Stop(String),
74 #[error("io: {0}")]
75 Io(#[from] std::io::Error),
76}
77
78pub type Result<T> = std::result::Result<T, BrowserError>;
79
80pub(crate) fn cdp<E: std::fmt::Display>(e: E) -> BrowserError {
81 BrowserError::Cdp(e.to_string())
82}