p2panda_rs/graph/
error.rs

1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3//! Error types for creating and traversing an operation graph.
4use thiserror::Error;
5
6/// Error types for methods of `graph` module.
7#[derive(Error, Debug, Clone)]
8#[allow(missing_copy_implementations)]
9pub enum GraphError {
10    /// Cycle detected in graph.
11    #[error("Cycle detected")]
12    CycleDetected,
13
14    /// Cycle detected or graph missing dependencies.
15    #[error("Badly formed graph")]
16    BadlyFormedGraph,
17
18    /// No root node found in graph.
19    #[error("No root node found")]
20    NoRootNode,
21
22    /// There can't be more than one root node in a graph.
23    #[error("Multiple root nodes found")]
24    MultipleRootNodes,
25
26    /// Requested node not found in graph.
27    #[error("Node not found in graph")]
28    NodeNotFound,
29
30    /// Requested trim nodes not found in graph.
31    #[error("Requested trim nodes not found in graph")]
32    InvalidTrimNodes,
33
34    /// Requested trim nodes not found in graph.
35    #[error(transparent)]
36    ReducerError(#[from] ReducerError),
37}
38
39/// Error types for `Reducer` trait.
40#[derive(Error, Debug, Clone)]
41#[allow(missing_copy_implementations)]
42pub enum ReducerError {
43    /// Error occurred when performing reducer function.
44    #[error("Could not perform reducer function: {0}")]
45    Custom(String),
46}