Skip to main content

xa11y_core/
error.rs

1use crate::role::Role;
2
3/// Result type alias for xa11y operations.
4pub type Result<T> = std::result::Result<T, Error>;
5
6/// Structured error type for xa11y operations.
7/// Designed to be informative across FFI boundaries.
8#[derive(Debug, thiserror::Error)]
9pub enum Error {
10    /// Accessibility permissions not granted.
11    #[error("Permission denied: {instructions}")]
12    PermissionDenied { instructions: String },
13
14    /// No element matched the selector.
15    #[error("No element matched selector: {selector}")]
16    SelectorNotMatched { selector: String },
17
18    /// The node's platform handle is stale and re-traversal could not relocate it.
19    #[error("Element stale: could not relocate element")]
20    ElementStale { selector: String },
21
22    /// The requested action is not supported by this element.
23    #[error("Action {action} not supported on {role}")]
24    ActionNotSupported { action: String, role: Role },
25
26    /// Text value input is not supported for this element on this platform.
27    #[error("Text value input not supported for this element")]
28    TextValueNotSupported,
29
30    /// A wait_for or wait_for_event call exceeded its timeout.
31    #[error("Timeout after {elapsed:?}")]
32    Timeout { elapsed: std::time::Duration },
33
34    /// The selector string could not be parsed.
35    #[error("Invalid selector '{selector}': {message}")]
36    InvalidSelector { selector: String, message: String },
37
38    /// Invalid argument to an action method.
39    #[error("Invalid action data: {message}")]
40    InvalidActionData { message: String },
41
42    /// A platform-specific error occurred.
43    #[error("Platform error ({code}): {message}")]
44    Platform { code: i64, message: String },
45}