ag_session/execution_graph/
error.rs1#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error)]
5pub enum GraphContractError {
6 #[error("graph field `{0}` must not be blank")]
8 EmptyField(&'static str),
9 #[error("graph must contain at least one node")]
11 EmptyGraph,
12 #[error("duplicate graph {kind}: {id}")]
14 Duplicate {
15 kind: &'static str,
17 id: String,
19 },
20 #[error("unknown graph node: {0}")]
22 UnknownNode(String),
23 #[error("unknown output `{output}` of graph node `{node}`")]
25 UnknownOutput {
26 node: String,
28 output: String,
30 },
31 #[error("graph dependencies contain a cycle")]
33 Cycle,
34 #[error("input `{0}` requires a dependency gate for its producing output")]
36 UngatedInput(String),
37 #[error("invalid graph execution profile: {0}")]
39 InvalidProfile(&'static str),
40 #[error("graph node environment belongs to a different session")]
42 ForeignEnv,
43 #[error("graph result does not match {0}")]
45 ResultMismatch(&'static str),
46 #[error("graph result has not satisfied the input gate")]
48 UnsatisfiedGate,
49}
50
51impl GraphContractError {
52 pub(super) fn require(value: &str, field: &'static str) -> Result<(), Self> {
54 if value.trim().is_empty() {
55 return Err(Self::EmptyField(field));
56 }
57
58 Ok(())
59 }
60}