Skip to main content

legalis_sim/
error.rs

1//! Error types for simulation operations.
2
3use thiserror::Error;
4
5/// Errors that can occur during simulation.
6#[derive(Debug, Error)]
7pub enum SimulationError {
8    /// Invalid configuration provided
9    #[error("Invalid configuration: {0}")]
10    InvalidConfiguration(String),
11
12    /// Population is empty
13    #[error("Population cannot be empty")]
14    EmptyPopulation,
15
16    /// No statutes provided
17    #[error("At least one statute is required")]
18    NoStatutes,
19
20    /// Simulation was cancelled
21    #[error("Simulation was cancelled")]
22    Cancelled,
23
24    /// I/O error during export/import
25    #[error("I/O error: {0}")]
26    Io(#[from] std::io::Error),
27
28    /// Serialization error
29    #[error("Serialization error: {0}")]
30    Serialization(#[from] serde_json::Error),
31
32    /// Invalid date range
33    #[error("Invalid date range: start must be before end")]
34    InvalidDateRange,
35
36    /// Temporal configuration error
37    #[error("Temporal configuration error: {0}")]
38    TemporalConfig(String),
39
40    /// Population generation error
41    #[error("Population generation error: {0}")]
42    PopulationGeneration(String),
43
44    /// Checkpoint error
45    #[error("Checkpoint error: {0}")]
46    Checkpoint(String),
47
48    /// Configuration error
49    #[error("Configuration error: {0}")]
50    ConfigurationError(String),
51
52    /// Execution error
53    #[error("Execution error: {0}")]
54    ExecutionError(String),
55
56    /// Invalid population
57    #[error("Invalid population: {0}")]
58    InvalidPopulation(String),
59
60    /// Invalid parameter or value
61    #[error("Invalid parameter: {0}")]
62    InvalidParameter(String),
63}
64
65/// Result type for simulation operations.
66pub type SimResult<T> = Result<T, SimulationError>;