Skip to main content

pedant_graph/analysis/
error.rs

1//! Why an analysis or one of its queries refused.
2//!
3//! Every variant names the exact identity, count, or ceiling that failed. No
4//! refusal answers with a partial result, and none panics.
5
6use crate::id::GraphNodeId;
7
8/// A refusal taken while building or querying one analysis.
9#[derive(Debug, thiserror::Error)]
10pub enum GraphAnalysisError {
11    /// A query named a node this graph holds no record for.
12    #[error("node {} is not in this graph", node.index())]
13    UnknownNode {
14        /// The identity that named nothing.
15        node: GraphNodeId,
16    },
17    /// The graph states more nodes than the stated ceiling admits.
18    #[error("the graph states {count} nodes, above the ceiling of {limit}")]
19    NodeLimitExceeded {
20        /// How many nodes the graph states.
21        count: u32,
22        /// The ceiling the caller stated.
23        limit: u32,
24    },
25    /// The selection admits more edges than the stated ceiling allows.
26    #[error("the selection admits {count} edges, above the ceiling of {limit}")]
27    SelectedEdgeLimitExceeded {
28        /// How many edges the selection admits.
29        count: u32,
30        /// The ceiling the caller stated.
31        limit: u32,
32    },
33    /// A query asked to walk further than the stated ceiling allows.
34    #[error("a depth of {requested} is above the ceiling of {limit}")]
35    DepthLimitExceeded {
36        /// The depth the query asked for.
37        requested: u32,
38        /// The ceiling the caller stated.
39        limit: u32,
40    },
41    /// Betweenness over this selection costs more than the stated ceiling.
42    #[error("betweenness needs {required} steps, above the ceiling of {limit}")]
43    BetweennessWorkLimitExceeded {
44        /// The upper bound on the work the selection would cost.
45        required: u64,
46        /// The ceiling the caller stated.
47        limit: u64,
48    },
49    /// The betweenness work bound does not fit the width it is counted in.
50    #[error("the betweenness work bound overflows its own counter")]
51    BetweennessWorkOverflow,
52    /// Partition derivation observed a node no container owns.
53    ///
54    /// Graph construction proves every node is reachable from one container
55    /// root, and no public constructor can state a graph that is not, so this
56    /// is the exhaustiveness branch of a guarantee rather than a reachable
57    /// refusal.
58    #[error("node {} is owned by no container", node.index())]
59    ConsumedGraphInvariant {
60        /// The node no container ancestor answers for.
61        node: GraphNodeId,
62    },
63}