1use crate::graph::NodeHandle;
2use crate::node::Name;
3
4use std::any::TypeId;
5use std::fmt;
6
7#[derive(Clone, Debug)]
9pub enum Error {
10 InvalidNodeHandle(NodeHandle),
12
13 UnknownInput(Name),
15
16 UnknownOutput(Name),
18
19 Incompatible { input: TypeId, output: TypeId },
21
22 Cycle(NodeHandle),
24}
25
26impl fmt::Display for Error {
27 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
28 match self {
29 Self::InvalidNodeHandle(handle) => {
30 write!(f, "The node handle ({}) is invalid", handle.0)
31 }
32 Self::UnknownInput(name) => write!(f, "The input {} does not exist", name),
33 Self::UnknownOutput(name) => write!(f, "The output {} does not exist", name),
34 Self::Incompatible { .. } => write!(f, "The input and the output are not compatible"),
35 Self::Cycle(handle) => write!(f, "The node ({}) depends on itself", handle.0),
36 }
37 }
38}
39
40pub type Result<T> = std::result::Result<T, Error>;