ag_session/execution_graph/
error.rs1#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error)]
3pub enum GraphContractError {
4 #[error("graph field `{0}` must not be blank")]
6 EmptyField(&'static str),
7 #[error("graph must contain at least one node")]
9 EmptyGraph,
10 #[error("duplicate graph {kind}: {id}")]
12 Duplicate {
13 kind: &'static str,
15 id: String,
17 },
18 #[error("unknown graph node: {0}")]
20 UnknownNode(String),
21 #[error("unknown output `{output}` of graph node `{node}`")]
23 UnknownOutput {
24 node: String,
26 output: String,
28 },
29 #[error("graph dependencies contain a cycle")]
31 Cycle,
32 #[error("input `{0}` requires a dependency gate for its producing output")]
34 UngatedInput(String),
35 #[error("invalid graph execution profile: {0}")]
37 InvalidProfile(&'static str),
38 #[error("graph node environment belongs to a different session")]
40 ForeignEnv,
41 #[error("graph result does not match {0}")]
43 ResultMismatch(&'static str),
44 #[error("graph result has not satisfied the input gate")]
46 UnsatisfiedGate,
47}
48
49impl GraphContractError {
50 pub(super) fn require(value: &str, field: &'static str) -> Result<(), Self> {
52 if value.trim().is_empty() {
53 return Err(Self::EmptyField(field));
54 }
55
56 Ok(())
57 }
58}