1use thiserror::Error;
2
3#[derive(Debug, Error, Clone, PartialEq, Eq)]
5pub enum LunarError {
6 #[error("Invalid solar date: {year:04}-{month:02}-{day:02}")]
8 InvalidSolarDate { year: i32, month: u8, day: u8 },
9 #[error("Invalid lunar date: {year:04}-{month:02}-{day:02}, is_leap_month={is_leap_month}")]
11 InvalidLunarDate {
12 year: i32,
13 month: u8,
14 day: u8,
15 is_leap_month: bool,
16 },
17 #[error("Year {year} is out of supported range")]
19 YearOutOfRange { year: i32 },
20 #[error("Invalid time: {hour:02}:{minute:02}")]
22 InvalidTime { hour: u8, minute: u8 },
23 #[error("Invalid time index: {time_index} (expected 0..=12)")]
25 InvalidTimeIndex { time_index: u8 },
26 #[error("Year {year} is outside the supported solar-term range")]
28 SolarTermOutOfRange { year: i32 },
29}
30
31#[derive(Debug, Error, Clone, PartialEq, Eq)]
33pub enum StemBranchError {
34 #[error("Invalid stem-branch pair: {stem:?} - {branch:?}")]
37 InvalidStemBranchPair {
38 stem: crate::stem_branch::HeavenlyStem,
39 branch: crate::stem_branch::EarthlyBranch,
40 },
41}