1use crate::{NodeId, PanelId};
2
3#[non_exhaustive]
5#[derive(Debug, thiserror::Error)]
6pub enum ConstraintError {
7 #[error("{0} is NaN")]
9 IsNan(&'static str),
10 #[error("{0} is negative")]
12 IsNegative(&'static str),
13 #[error("{0} is infinite")]
15 IsInfinite(&'static str),
16 #[error("grow and fixed are mutually exclusive")]
18 GrowFixedExclusive,
19 #[error("min exceeds max")]
21 MinExceedsMax,
22 #[error("delta must be finite")]
24 DeltaNotFinite,
25 #[error("grid span {0} exceeds u16 max")]
27 GridSpanOverflow(usize),
28}
29
30#[non_exhaustive]
32#[derive(Debug, thiserror::Error)]
33pub enum TreeError {
34 #[error("root is not set")]
36 RootNotSet,
37 #[error("root already set")]
39 RootAlreadySet,
40 #[error("root node {0} missing from arena")]
42 RootMissing(NodeId),
43 #[error("panel ID counter exhausted")]
45 PanelIdExhausted,
46 #[error("node arena size exceeds u32 capacity")]
48 ArenaOverflow,
49 #[error("node arena index exceeds u32 capacity")]
51 ArenaIndexOverflow,
52 #[error("node {parent} references missing child {child}")]
54 MissingChild {
55 parent: NodeId,
57 child: NodeId,
59 },
60 #[error("node {0} has no parent entry")]
62 NoParentEntry(NodeId),
63 #[error("parent {parent} of node {child} missing from arena")]
65 ParentMissing {
66 parent: NodeId,
68 child: NodeId,
70 },
71 #[error("parent_map says {parent} is parent of {child}, but children list disagrees")]
73 ParentChildMismatch {
74 parent: NodeId,
76 child: NodeId,
78 },
79 #[error("at least one kind required")]
81 NoKinds,
82 #[error("active index {active} out of bounds for {len} panels")]
84 ActiveOutOfBounds {
85 active: usize,
87 len: usize,
89 },
90 #[error("dashboard requires at least one card")]
92 DashboardNoCards,
93 #[error("dashboard columns must be at least 1")]
95 DashboardNoColumns,
96 #[error("window size must be at least 1")]
98 WindowSizeZero,
99 #[error("empty after rebuild")]
101 EmptyAfterRebuild,
102 #[error("no root")]
104 NoRoot,
105 #[error("column count must be at least 1")]
107 ColumnsCountZero,
108 #[error("{0}")]
110 Dynamic(Box<str>),
111}
112
113#[non_exhaustive]
115#[derive(Debug, thiserror::Error)]
116pub enum ViewportError {
117 #[error("dimension is NaN")]
119 IsNan,
120 #[error("dimension is negative")]
122 IsNegative,
123 #[error("dimension is infinite")]
125 IsInfinite,
126 #[error("no saved constraints for panel {0}")]
128 NoSavedConstraints(PanelId),
129}
130
131#[non_exhaustive]
133#[derive(Debug, thiserror::Error)]
134pub enum MutationError {
135 #[error("no strategy set")]
137 NoStrategy,
138 #[error("no focused panel")]
140 NoFocusedPanel,
141 #[error("focused panel has no parent")]
143 FocusedNoParent,
144 #[error("parent is not a container")]
146 ParentNotContainer,
147 #[error("panel has no parent")]
149 PanelNoParent,
150 #[error("panel is the only child")]
152 OnlyChild,
153 #[error("resize_boundary requires all siblings to be panels")]
155 SiblingsNotPanels,
156 #[error("resize_boundary requires all siblings to use grow constraints")]
158 SiblingsNotGrow,
159 #[error("no collapsed slots to uncollapse")]
161 NoCollapsedSlots,
162 #[error("slot has no saved constraints")]
164 SlotNoSavedConstraints,
165 #[error("move not supported for this layout")]
167 MoveNotSupported,
168}
169
170#[non_exhaustive]
172#[derive(Debug, thiserror::Error)]
173pub enum PaneError {
174 #[error("panel not found: {0}")]
176 PanelNotFound(PanelId),
177
178 #[error("invalid constraint: {0}")]
180 InvalidConstraint(ConstraintError),
181
182 #[error("node not found: {0}")]
184 NodeNotFound(NodeId),
185
186 #[error("tree validation failed: {0}")]
188 InvalidTree(TreeError),
189
190 #[error("invalid viewport: {0}")]
192 InvalidViewport(ViewportError),
193
194 #[error("invalid mutation: {0}")]
196 InvalidMutation(MutationError),
197
198 #[error("sequence index {0} out of bounds for length {1}")]
200 SequenceOutOfBounds(usize, usize),
201}