#[non_exhaustive]pub enum Error {
Show 13 variants
PermissionDenied {
instructions: String,
},
AccessibilityNotEnabled {
app: String,
instructions: String,
},
SelectorNotMatched {
selector: String,
diagnosis: Option<Box<Diagnosis>>,
},
ElementStale {
selector: String,
},
ActionNotSupported {
action: String,
role: Role,
},
TextValueNotSupported,
Timeout {
elapsed: Duration,
diagnosis: Option<Box<Diagnosis>>,
},
InvalidSelector {
selector: String,
message: String,
},
InvalidActionData {
message: String,
},
InvalidConfig {
message: String,
},
NoElementBounds,
Unsupported {
feature: String,
},
Platform {
code: i64,
message: String,
},
}Expand description
Structured error type for xa11y operations. Designed to be informative across FFI boundaries.
Construct SelectorNotMatched and
Timeout through Error::selector_not_matched /
Error::timeout and attach context with Error::diagnose — see the
module docs for the diagnosis pattern.
#[non_exhaustive]: new failure modes arrive with every backend and
platform quirk, so downstream match arms need a _ fallback. Before
this attribute the bindings’ exhaustive matches were what forced a new
variant to be mapped; that guard now lives in
cargo xtask check-bindings-parity, which fails when a variant is not
referenced by both binding error mappers (see [[types.variant_coverage]]
in bindings/parity_allowlist.toml).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
PermissionDenied
Accessibility permissions not granted.
AccessibilityNotEnabled
The target application advertises an accessibility tree but its
content is empty because the app’s accessibility bridge is disabled
(Chromium/Electron on Linux without --force-renderer-accessibility,
for example).
SelectorNotMatched
No element matched the selector.
Doubles as the “not yet” retry signal inside poll loops, so bare
construction stays cheap; terminal sites attach a Diagnosis.
ElementStale
The node’s platform handle is stale and re-traversal could not relocate it.
ActionNotSupported
The requested action is not supported by this element.
TextValueNotSupported
Text value input is not supported for this element on this platform.
Timeout
A wait operation exceeded its timeout.
Always carries what the wait was for via its Diagnosis — a bare
“Timeout after Ns” tells the consumer nothing actionable (tenet 6).
InvalidSelector
The selector string could not be parsed.
InvalidActionData
Invalid argument to an action method.
InvalidConfig
Process-wide configuration is invalid (e.g. an unparsable
XA11Y_DEFAULT_TIMEOUT environment variable).
NoElementBounds
The element has no bounds (e.g. an off-screen or virtual node), so a screen point can’t be computed for input simulation.
Unsupported
The requested operation has no implementation on this platform/session (e.g. pointer warp on Wayland without a portal grant).
Platform
A platform-specific error occurred.
Implementations§
Source§impl Error
impl Error
Sourcepub fn selector_not_matched(selector: impl Into<String>) -> Self
pub fn selector_not_matched(selector: impl Into<String>) -> Self
Construct a bare Error::SelectorNotMatched (no diagnosis).
This is the cheap form for poll-loop retry signals; attach context at
the terminal site with diagnose.
Sourcepub fn timeout(elapsed: Duration) -> Self
pub fn timeout(elapsed: Duration) -> Self
Construct a bare Error::Timeout (no diagnosis).
Prefer attaching a Diagnosis with diagnose
before the error reaches a consumer — see tenet 6.
Sourcepub fn diagnose(self, diagnosis: Diagnosis) -> Self
pub fn diagnose(self, diagnosis: Diagnosis) -> Self
Attach (or replace) a Diagnosis on errors that carry one.
Supported variants: SelectorNotMatched
and Timeout. Other variants are returned unchanged —
their primary fields already identify the failure, and silently
growing a diagnosis field on them would not be rendered. An empty
diagnosis is normalized to None.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()