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("no element matched '{0}'")]
37 NoElement(String),
38 #[error("selector '{0}' is ambiguous ({1} matches)")]
39 Ambiguous(String, u64),
40 #[error("element '{0}' is not visible or has no box")]
41 NotInteractable(String),
42 #[error("unknown page '{0}'")]
43 UnknownPage(String),
44 #[error("unknown key '{0}'")]
45 UnknownKey(String),
46 #[error("timed out: {0}")]
47 Timeout(String),
48 #[error("invalid argument: {0}")]
49 Invalid(String),
50 #[error("denied before effect: {0}")]
52 Denied(String),
53 #[error("blocked by network policy: {0}")]
55 Blocked(crate::policy::PolicyDenial),
56 #[error("consent: {0}")]
58 Consent(String),
59 #[error("unsupported: {0}")]
61 Unsupported(String),
62 #[error("io: {0}")]
63 Io(#[from] std::io::Error),
64}
65
66pub type Result<T> = std::result::Result<T, BrowserError>;
67
68pub(crate) fn cdp<E: std::fmt::Display>(e: E) -> BrowserError {
69 BrowserError::Cdp(e.to_string())
70}