1use super::NodeIndex;
4use crate::any::TypeInfo;
5use crate::tuple::TupleIndex;
6
7#[derive(Debug)]
9#[allow(variant_size_differences)]
10pub enum Error {
11 HasStarted(NodeIndex),
13 OutOfRange(TupleIndex),
15 TypeMismatch {
17 input: TypeInfo,
19 output: TypeInfo,
21 },
22 WouldCycle,
24}
25
26impl std::fmt::Display for Error {
27 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28 match self {
29 Self::HasStarted(index) => f.debug_tuple("Error::HasStarted").field(index).finish(),
30 Self::OutOfRange(len) => f.debug_tuple("Error::OutOfRange").field(len).finish(),
31 Self::TypeMismatch { input, output } => f
32 .debug_struct("Error::TypeMismatch")
33 .field("input", input)
34 .field("output", output)
35 .finish(),
36 Self::WouldCycle => f.debug_tuple("Error::WouldCycle").finish(),
37 }
38 }
39}
40
41impl std::error::Error for Error {}
42
43#[derive(Debug)]
45pub struct ErrorWithTask<T> {
46 pub error: Error,
48 pub task: T,
50}
51
52impl<T: std::fmt::Debug> std::fmt::Display for ErrorWithTask<T> {
53 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
54 f.debug_struct("ErrorWithTask")
55 .field("error", &self.error)
56 .field("task", &self.task)
57 .finish()
58 }
59}
60
61impl<T: std::fmt::Debug> std::error::Error for ErrorWithTask<T> {}