trading_calendar/
error.rs1use chrono::NaiveDate;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
8pub enum CalendarError {
9 #[error("Date {0} is outside supported range (2020-2030). Please use a date within the supported range.")]
11 DateOutOfRange(NaiveDate),
12
13 #[error("Invalid time for market operation: {0}. Times must be in 24-hour format (HH:MM:SS).")]
15 InvalidTime(String),
16
17 #[error("No trading day found within search period. The market may be closed for an extended period.")]
19 NoTradingDayFound,
20
21 #[error("Invalid date calculation: {0}")]
23 InvalidDateCalculation(String),
24
25 #[error("Invalid configuration: {0}")]
27 InvalidConfiguration(String),
28
29 #[error("Invalid session: end time must be after start time for regular sessions")]
31 InvalidSession,
32}
33
34pub type Result<T> = std::result::Result<T, CalendarError>;