use crate::graph::NodeHandle;
use crate::node::Name;
use std::any::TypeId;
use std::fmt;
#[derive(Clone, Debug)]
pub enum Error {
InvalidNodeHandle(NodeHandle),
UnknownInput(Name),
UnknownOutput(Name),
Incompatible { input: TypeId, output: TypeId },
Cycle(NodeHandle),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::InvalidNodeHandle(handle) => {
write!(f, "The node handle ({}) is invalid", handle.0)
}
Self::UnknownInput(name) => write!(f, "The input {} does not exist", name),
Self::UnknownOutput(name) => write!(f, "The output {} does not exist", name),
Self::Incompatible { .. } => write!(f, "The input and the output are not compatible"),
Self::Cycle(handle) => write!(f, "The node ({}) depends on itself", handle.0),
}
}
}
pub type Result<T> = std::result::Result<T, Error>;