1use crate::graph::{Edge, EdgeID, PortIdx};
2use firewheel_core::{
3 channel_config::ChannelCount,
4 node::{NodeError, NodeID},
5};
6
7#[cfg(not(feature = "std"))]
8use bevy_platform::prelude::String;
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
12pub enum AddEdgeError {
13 #[error("Could not add edge: could not find source node with ID {0:?}")]
15 SrcNodeNotFound(NodeID),
16 #[error("Could not add edge: could not find destination node with ID {0:?}")]
18 DstNodeNotFound(NodeID),
19 #[error(
21 "Input port idx {port_idx:?} is out of range on node {node:?} with {num_in_ports:?} input ports"
22 )]
23 InPortOutOfRange {
24 node: NodeID,
25 port_idx: PortIdx,
26 num_in_ports: ChannelCount,
27 },
28 #[error(
30 "Output port idx {port_idx:?} is out of range on node {node:?} with {num_out_ports:?} output ports"
31 )]
32 OutPortOutOfRange {
33 node: NodeID,
34 port_idx: PortIdx,
35 num_out_ports: ChannelCount,
36 },
37 #[error("Could not add edge: cycle was detected")]
39 CycleDetected,
40}
41
42#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
45pub enum CompileGraphError {
46 #[error("Failed to compile audio graph: a cycle was detected")]
48 CycleDetected,
49 #[error(
51 "Failed to compile audio graph: input data contains an edge {0:?} referring to a non-existing node {1:?}"
52 )]
53 NodeOnEdgeNotFound(Edge, NodeID),
54 #[error(
56 "Failed to compile audio graph: input data contains multiple nodes with the same ID {0:?}"
57 )]
58 NodeIDNotUnique(NodeID),
59 #[error(
61 "Failed to compile audio graph: input data contains multiple edges with the same ID {0:?}"
62 )]
63 EdgeIDNotUnique(EdgeID),
64 #[error("Failed to construct a node's processor: {0}")]
66 ProcessorConstructionFailed(String),
67}
68
69#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
72pub enum ActivateError {
73 #[error("Failed to activate Firewheel context: The Firewheel context is already active")]
81 AlreadyActive,
82 #[error("Failed to activate Firewheel context: Audio graph failed to compile: {0}")]
84 GraphCompileError(#[from] CompileGraphError),
85}
86
87#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
89pub enum UpdateError {
90 #[error("The Firewheel context to processor message channel is full")]
92 MsgChannelFull,
93 #[error("The audio graph failed to compile: {0}")]
95 GraphCompileError(#[from] CompileGraphError),
96}
97
98#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
100pub enum RemoveNodeError {
101 #[error("Removing the graph in node is not allowed")]
103 CannotRemoveGraphInNode,
104 #[error("Removing the graph out node is not allowed")]
106 CannotRemoveGraphOutNode,
107}
108
109#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
111pub enum DeactivateError {
112 #[error("Timed out waiting for the Firewheel context to deactivate")]
113 TimedOut,
114}
115
116#[derive(Debug, thiserror::Error)]
117pub enum ModifyGraphError {
118 #[error("{0}")]
120 NodeError(NodeError),
121 #[error("{0}")]
122 RemoveNodeError(#[from] RemoveNodeError),
124 #[error("{0}")]
126 AddEdgeError(#[from] AddEdgeError),
127 #[error("{0}")]
129 UpdateError(#[from] UpdateError),
130 #[error("{0}")]
133 CompileGraphError(#[from] CompileGraphError),
134}
135
136impl From<NodeError> for ModifyGraphError {
137 fn from(e: NodeError) -> Self {
138 Self::NodeError(e)
139 }
140}