a11y_kit/error.rs
1//! Typed audit failures. Every variant names the node — a gate that says
2//! "something is wrong with the a11y tree" is a gate nobody can fix.
3
4use crate::node::NodeId;
5
6/// Why an accessibility tree failed its audit.
7#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
8pub enum AuditError {
9 /// Two nodes share an id.
10 #[error("duplicate node id {0}")]
11 DuplicateId(NodeId),
12 /// A parent or relation points at a node that does not exist.
13 #[error("node {node} references missing node {target}")]
14 DanglingReference {
15 /// The referencing node.
16 node: NodeId,
17 /// The missing node.
18 target: NodeId,
19 },
20 /// The parent chain loops.
21 #[error("node {node} is part of a parent cycle")]
22 Cycle {
23 /// A node on the cycle.
24 node: NodeId,
25 },
26 /// An interactive role has no accessible name.
27 #[error("interactive node {0} has no accessible name")]
28 MissingAccessibleName(NodeId),
29 /// More than one node claims focus.
30 #[error("multiple nodes claim focus: {0:?}")]
31 MultipleFocus(Vec<NodeId>),
32 /// The focused node is not reachable from any root (an orphan subtree).
33 #[error("focused node {0} is unreachable from any root")]
34 UnreachableFocus(NodeId),
35}