1use thiserror::Error;
4
5#[derive(Debug, Clone, PartialEq, Eq, Error)]
7pub enum SimulationError {
8 #[error("Simulation has been shut down")]
10 SimulationShutdown,
11 #[error("Invalid simulation state: {0}")]
13 InvalidState(String),
14 #[error("I/O error: {0}")]
16 IoError(String),
17 #[error("Settle timeout: {pending_events} events still pending after {elapsed:?}")]
19 SettleTimeout {
20 pending_events: usize,
22 elapsed: std::time::Duration,
24 },
25}
26
27pub type SimulationResult<T> = Result<T, SimulationError>;
29
30impl From<std::io::Error> for SimulationError {
31 fn from(err: std::io::Error) -> Self {
32 SimulationError::IoError(err.to_string())
33 }
34}