Skip to main content

browser_info/
error.rs

1// ================================================================================================
2// Error type Definition  - エラー型定義
3// ================================================================================================
4
5use thiserror::Error;
6
7#[derive(Debug, Error)]
8pub enum BrowserInfoError {
9    /// No active window found
10    #[error("No active window found")]
11    WindowNotFound,
12
13    /// Active window is not a browser
14    #[error("Active window is not a browser")]
15    NotABrowser,
16
17    /// Failed to extract URL from browser
18    #[error("Failed to extract URL from browser: {0}")]
19    UrlExtractionFailed(String),
20
21    /// Browser detection failed
22    #[error("Browser detection failed: {0}")]
23    BrowserDetectionFailed(String),
24
25    /// Platform-specific error
26    #[error("Platform-specific error: {0}")]
27    PlatformError(String),
28
29    /// Invalid URL format
30    #[error("Invalid URL format: {0}")]
31    InvalidUrl(String),
32
33    /// Timeout during operation
34    #[error("Timeout during operation")]
35    Timeout,
36
37    /// Permission denied (e.g., accessibility permissions on macOS)
38    #[error(
39        "Permission denied: grant Automation access to the browser in System Settings > Privacy & Security > Automation"
40    )]
41    PermissionDenied,
42
43    #[error("Network error: {0}")]
44    NetworkError(String),
45
46    #[error("JSON parse error: {0}")]
47    ParseError(String),
48
49    #[error("No active tabs found")]
50    NoActiveTabs,
51
52    #[error("Chrome DevTools not available")]
53    ChromeDevToolsNotAvailable,
54
55    /// Other error
56    #[error("Other error: {0}")]
57    Other(String),
58}
59
60pub type BrowserError = BrowserInfoError;