Skip to main content

rmp_route_optimizer/
error.rs

1//! Error types for route optimization
2
3use thiserror::Error;
4
5/// Result type for optimization operations
6pub type Result<T> = std::result::Result<T, OptimizationError>;
7
8/// Errors that can occur during route optimization
9#[derive(Debug, Error)]
10pub enum OptimizationError {
11    /// Graph has no nodes
12    #[error("Graph must contain at least one node")]
13    EmptyGraph,
14
15    /// Graph has no edges
16    #[error("Graph must contain at least one edge")]
17    NoEdges,
18
19    /// Start node not found in graph
20    #[error("Start node {0} not found in graph")]
21    StartNodeNotFound(i64),
22
23    /// Graph is not connected
24    #[error("Graph is not connected - cannot create Eulerian circuit")]
25    DisconnectedGraph,
26
27    /// Invalid edge configuration
28    #[error("Invalid edge: {0}")]
29    InvalidEdge(String),
30
31    /// Graph has too many odd-degree vertices
32    #[error("Graph has {0} odd-degree vertices (maximum supported: 100)")]
33    TooManyOddVertices(usize),
34
35    /// Failed to augment graph
36    #[error("Failed to make graph Eulerian: {0}")]
37    AugmentationFailed(String),
38
39    /// Circuit construction failed
40    #[error("Failed to construct Eulerian circuit: {0}")]
41    CircuitConstructionFailed(String),
42}