Skip to main content

crdt_graph/
error.rs

1use std::fmt::Debug;
2
3use thiserror::Error;
4
5/// Errors that can occur when performing operations on a [`TwoPTwoPGraph`](crate::TwoPTwoPGraph).
6#[derive(Error, Debug)]
7pub enum TwoPTwoPGraphError<Id>
8where
9    Id: Debug,
10{
11    /// A vertex with the given ID has already been added.
12    #[error("Vertex {0} already exists")]
13    VertexAlreadyExists(Id),
14    /// The referenced vertex does not exist in `V_A \ V_R`.
15    #[error("Vertex {0} does not exists")]
16    VertexDoesNotExists(Id),
17    /// An edge with the given ID has already been added.
18    #[error("Edge already exists")]
19    EdgeAlreadyExists(Id),
20    /// The referenced edge does not exist in `E_A \ E_R`.
21    #[error("Edge does not exists")]
22    EdgeDoesNotExists(Id),
23    /// Cannot remove the vertex because it still has an active (non-removed) edge.
24    #[error("Vertex {0} has edge {1}")]
25    VertexHasEdge(Id, Id),
26    /// Downstream precondition failure: the corresponding `addVertex` has not been delivered yet.
27    #[error("addVertex({0}) not yet delivered")]
28    AddVertexNotDelivered(Id),
29    /// Downstream precondition failure: the corresponding `addEdge` has not been delivered yet.
30    #[error("addEdge({0}) not yet delivered")]
31    AddEdgeNotDelivered(Id),
32}