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 /// The target application advertises an accessibility tree but its
15 /// content is empty because the app's accessibility bridge is disabled
16 /// (Chromium/Electron on Linux without `--force-renderer-accessibility`,
17 /// for example).
18 #[error("Accessibility not enabled for {app}: {instructions}")]
19 AccessibilityNotEnabled { app: String, instructions: String },
20
21 /// No element matched the selector.
22 #[error("No element matched selector: {selector}")]
23 SelectorNotMatched { selector: String },
24
25 /// The node's platform handle is stale and re-traversal could not relocate it.
26 #[error("Element stale: could not relocate element for selector: {selector}")]
27 ElementStale { selector: String },
28
29 /// The requested action is not supported by this element.
30 #[error("Action {action} not supported on {role}")]
31 ActionNotSupported { action: String, role: Role },
32
33 /// Text value input is not supported for this element on this platform.
34 #[error("Text value input not supported for this element")]
35 TextValueNotSupported,
36
37 /// A wait_for or wait_for_event call exceeded its timeout.
38 #[error("Timeout after {elapsed:?}")]
39 Timeout { elapsed: std::time::Duration },
40
41 /// The selector string could not be parsed.
42 #[error("Invalid selector '{selector}': {message}")]
43 InvalidSelector { selector: String, message: String },
44
45 /// Invalid argument to an action method.
46 #[error("Invalid action data: {message}")]
47 InvalidActionData { message: String },
48
49 /// The element has no bounds (e.g. an off-screen or virtual node), so a
50 /// screen point can't be computed for input simulation.
51 #[error("Element has no bounds")]
52 NoElementBounds,
53
54 /// The requested operation has no implementation on this platform/session
55 /// (e.g. pointer warp on Wayland without a portal grant).
56 #[error("Unsupported: {feature}")]
57 Unsupported { feature: String },
58
59 /// A platform-specific error occurred.
60 #[error("Platform error ({code}): {message}")]
61 Platform { code: i64, message: String },
62}