pedant_graph/error.rs
1//! Why a graph build refused.
2//!
3//! Every variant names the exact join or ceiling that failed. No refusal
4//! returns a partial graph, none panics, and none exposes the snapshot identity
5//! bytes it compared.
6
7use crate::limits::GraphCollection;
8
9/// A refusal taken while projecting one resolution into a graph.
10#[derive(Debug, thiserror::Error)]
11pub enum GraphBuildError {
12 /// The supplied snapshot and resolution were requested for other targets.
13 #[error("the snapshot and the resolution describe different root targets")]
14 RootTargetMismatch,
15 /// The supplied snapshot is not the one the resolution was validated
16 /// against, even though both name the same root target.
17 #[error("the snapshot is not the one this resolution was validated against")]
18 SnapshotFingerprintMismatch,
19 /// A report unit has no graph container, or no source scope beneath one.
20 #[error("unit {unit} has no binding in this resolution")]
21 MissingUnitBinding {
22 /// The report-local unit identifier that no binding answers for.
23 unit: u32,
24 },
25 /// A report unit is bound to a build unit the supplied snapshot does not
26 /// hold, which is a binding that names nothing rather than a missing one.
27 #[error("unit {unit} is bound to a build unit this snapshot does not hold")]
28 DanglingUnitBinding {
29 /// The report-local unit identifier whose binding names nothing.
30 unit: u32,
31 },
32 /// Two report units are bound to one build unit, so one unit-qualified
33 /// source would have two owners.
34 #[error("report units {held} and {unit} are bound to one build unit")]
35 SharedUnitBinding {
36 /// The report-local unit identifier that bound the build unit first.
37 held: u32,
38 /// The report-local unit identifier that bound it again.
39 unit: u32,
40 },
41 /// A snapshot dependency edge names a build unit with no graph container.
42 #[error(
43 "dependency edge {edge} ({alias}) names a build unit this graph holds no container for"
44 )]
45 MissingDependencyUnit {
46 /// The edge's position among the snapshot's dependency edges.
47 edge: u32,
48 /// The namespace-local name that edge declares its target under.
49 alias: Box<str>,
50 },
51 /// A stated site names a source the bound unit does not instantiate.
52 #[error("unit {unit} instantiates no source at {path}")]
53 MissingSourceNode {
54 /// The report-local unit identifier the site belongs to.
55 unit: u32,
56 /// The normalized repository-relative path the site named.
57 path: Box<str>,
58 },
59 /// The report states a different number of references and resolution
60 /// records, so no pairing between them is stated at all.
61 #[error("the report states {references} references and {records} resolution records")]
62 ReferenceRecordMismatch {
63 /// How many references the report states.
64 references: u32,
65 /// How many resolution records the report states.
66 records: u32,
67 },
68 /// A stated join names a definition this graph holds no node for.
69 #[error("definition {definition} has no node in this graph")]
70 MissingDefinitionNode {
71 /// The report-local definition identifier that named nothing.
72 definition: u32,
73 },
74 /// An edge was produced for a reference record this graph does not hold.
75 #[error("reference {reference} has no record in this graph")]
76 MissingReferenceRecord {
77 /// The reference identity that answers for no record.
78 reference: u32,
79 },
80 /// A containment edge names a node this graph holds no record for.
81 #[error("containment names node {node}, which this graph holds no record for")]
82 UnknownContainmentNode {
83 /// The node identity the containment relation named.
84 node: u32,
85 },
86 /// One node is contained by more than one parent.
87 #[error("node {child} is contained by more than one parent, including {parent}")]
88 MultiplyContained {
89 /// One parent the child is contained by.
90 parent: u32,
91 /// The multiply-contained child.
92 child: u32,
93 },
94 /// One node below the unit roots is contained by nothing.
95 #[error("node {node} is contained by no parent and is not a unit root")]
96 UnparentedNode {
97 /// The node no containment edge claims.
98 node: u32,
99 },
100 /// One unit root is contained by another node.
101 #[error("unit root {root} is contained by node {parent}")]
102 RootHasParent {
103 /// The unit root that must own itself.
104 root: u32,
105 /// The node that claims it.
106 parent: u32,
107 },
108 /// One containment chain returns to a node it already visited.
109 #[error("node {node} contains itself through its own ancestors")]
110 ContainmentCycle {
111 /// The node the chain returned to.
112 node: u32,
113 },
114 /// One collection reached its configured ceiling.
115 #[error("the {collection} collection cannot exceed {limit} entries")]
116 CapacityExceeded {
117 /// Which collection refused the insertion.
118 collection: GraphCollection,
119 /// The ceiling that collection is bounded by.
120 limit: u32,
121 },
122}