Skip to main content

yggdrasil/
error.rs

1use thiserror::Error;
2
3pub type Result<T, E = SceneGraphError> = core::result::Result<T, E>;
4
5#[derive(Error, Debug)]
6pub enum SceneGraphError {
7    #[error("edge not found")]
8    EdgeNotFound,
9
10    #[error("node not found")]
11    NodeNotFound,
12
13    #[error("point not found")]
14    PointNotFound,
15
16    #[error("layer not found")]
17    LayerNotFound,
18
19    #[error("invalid layers for nesting: cannot nest layer {0} within layer {1}")]
20    InvalidLayersForNesting(u32, u32),
21
22    #[error("feature '{0}' not found")]
23    FeatureNotFound(String),
24
25    #[error("coordinates are required for this layer")]
26    CoordinatesRequired,
27
28    /// The position index refused a point.
29    ///
30    /// The kd-tree cannot split a full leaf whose points all share the same value on the
31    /// dimension it splits on, which is exactly what coplanar geometry produces once more
32    /// than a bucket's worth of points land on one plane.
33    #[error("failed to insert point into the position index: {0}")]
34    PosIndexInsertion(String),
35
36    /// The observer was given a direction that is not a viewing axis.
37    ///
38    /// A field of view is a cone about its direction, so one that cannot be
39    /// normalized, i.e. having zero-length or carrying a NaN or infinity, leaves the cone
40    /// with nothing to point along.
41    #[error("observer direction has no viewing axis")]
42    ObserverCreationError,
43
44    #[error("failed to parse scene graph: {0}")]
45    ParseError(String),
46}