Skip to main content

jamjet_ir/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum IrError {
5    #[error("node '{0}' references unknown tool '{1}'")]
6    UnknownToolRef(String, String),
7
8    #[error("node '{0}' references unknown model '{1}'")]
9    UnknownModelRef(String, String),
10
11    #[error("node '{0}' references unknown agent '{1}'")]
12    UnknownAgentRef(String, String),
13
14    #[error("node '{0}' references unknown MCP server '{1}'")]
15    UnknownMcpServer(String, String),
16
17    #[error("node '{0}' references unknown remote agent '{1}'")]
18    UnknownRemoteAgent(String, String),
19
20    #[error("edge from '{from}' to '{to}': target node does not exist")]
21    UnknownEdgeTarget { from: String, to: String },
22
23    #[error("node '{0}' is unreachable from the start node")]
24    UnreachableNode(String),
25
26    #[error("workflow has no start node defined")]
27    NoStartNode,
28
29    #[error("workflow has no terminal (end) path from node '{0}'")]
30    NoTerminalPath(String),
31
32    #[error("parallel node '{0}' and its join node '{1}' are mismatched")]
33    MismatchedParallelJoin(String, String),
34
35    #[error("schema incompatibility: node '{from}' output schema '{from_schema}' is incompatible with node '{to}' input schema '{to_schema}'")]
36    SchemaIncompatibility {
37        from: String,
38        from_schema: String,
39        to: String,
40        to_schema: String,
41    },
42
43    #[error("workflow version '{0}' is not valid semver")]
44    InvalidVersion(String),
45
46    #[error("duplicate node id: '{0}'")]
47    DuplicateNodeId(String),
48
49    #[error("JSON error: {0}")]
50    Json(#[from] serde_json::Error),
51
52    #[error("YAML error: {0}")]
53    Yaml(#[from] serde_yaml::Error),
54}
55
56pub type IrResult<T> = Result<T, IrError>;