flow_graph_interpreter/interpreter/
error.rs

1use wick_packet::Entity;
2
3use super::components::core::OpInitError;
4use super::executor::error::ExecutionError;
5use super::program::validator::error::{OperationInvalid, ValidationError};
6
7#[derive(thiserror::Error, Debug)]
8#[non_exhaustive]
9pub enum Error {
10  #[error(transparent)]
11  ExecutionError(#[from] ExecutionError),
12
13  #[error("{}", .0.iter().map(|e|e.to_string()).collect::<Vec<_>>().join(", "))]
14  ValidationError(Vec<OperationInvalid>),
15
16  #[error("Early error: {:?}", .0)]
17  EarlyError(ValidationError),
18
19  #[error("Could not find operation '{}' ({0}). Known operations are: {}",.0.operation_id(), .1.join(", "))]
20  OpNotFound(Entity, Vec<String>),
21
22  #[error("Could not find component '{}' ({0}). Namespaces handled by this resource are: {}", .0.component_id(), .1.join(", "))]
23  TargetNotFound(Entity, Vec<String>),
24
25  #[error("Can not invoke non-operation entity: {0}")]
26  InvalidEntity(Entity),
27
28  #[error("Error shutting down component: {0}")]
29  ComponentShutdown(String),
30
31  #[error("Shutdown failed: {0}")]
32  Shutdown(String),
33
34  #[error("Event loop panicked: {0}")]
35  EventLoopPanic(String),
36
37  #[error("Shutdown timed out")]
38  ShutdownTimeout,
39
40  #[error("Namespace '{0}' already exists, can not overwrite")]
41  DuplicateNamespace(String),
42
43  #[error(transparent)]
44  OperationInit(#[from] OpInitError),
45
46  #[error("Interpreter can only expose one component at a time, found multiple: {}", .0.join(", "))]
47  ExposedLimit(Vec<String>),
48
49  #[error("Could not render operation configuration: {0}")]
50  Configuration(String),
51}
52
53#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq)]
54pub enum StateError {
55  #[error("Payload for port '{0}' missing from input stream")]
56  PayloadMissing(String),
57  #[error(
58    "Could not find port named '{0}'. This can result from providing more input than a schematic has ports for."
59  )]
60  MissingPortName(String),
61  #[error("Attempted to access nonexistant component '{0}'")]
62  MissingComponent(String),
63  #[error("Attempted to start an instance ('{0}') more than once")]
64  InvocationMissing(String),
65  #[error("Tried to decrement pending counter for non-existent or zero ID.")]
66  TooManyComplete,
67}
68
69impl From<Vec<OperationInvalid>> for Error {
70  fn from(v: Vec<OperationInvalid>) -> Self {
71    Error::ValidationError(v)
72  }
73}