| 1 | #![allow(clippy::module_name_repetitions)] |
| 2 | use thiserror::Error; |
| 3 | |
| 4 | #[derive(Error, Debug, Clone, PartialEq, Eq)] |
| 5 | pub enum ParseError { |
| 6 | #[error("`{0}` is not a valid timezone.")] |
| 7 | InvalidTimezone(String), |
| 8 | #[error("`{value}` is not a valid datetime format for `{property}`.")] |
| 9 | InvalidDateTime { value: String, property: String }, |
| 10 | #[error("`{0}` is not a valid datetime format.")] |
| 11 | InvalidDateTimeFormat(String), |
| 12 | #[error("{property}:{value} is not a valid datetime in local timezone.")] |
| 13 | InvalidDateTimeInLocalTimezone { value: String, property: String }, |
| 14 | #[error("{property}:{value} is not a valid datetime in local timezone. This value is ambiguous and can be `{date1}` or `{date2}`")] |
| 15 | DateTimeInLocalTimezoneIsAmbiguous { |
| 16 | value: String, |
| 17 | property: String, |
| 18 | date1: String, |
| 19 | date2: String, |
| 20 | }, |
| 21 | #[error("`{0}` is not a valid frequency.")] |
| 22 | InvalidFrequency(String), |
| 23 | #[error("`{0}` is not a valid weekday. Valid values are `MO`, `TU`, `WE`, `TH`, `FR`, `SA` and `SU`.")] |
| 24 | InvalidWeekday(String), |
| 25 | #[error("`{0}` is not a valid weekday start. Valid values are `MO`, `TU`, `WE`, `TH`, `FR`, `SA` and `SU`.")] |
| 26 | InvalidWeekdayStart(String), |
| 27 | #[error("`{0}` is not a valid BYEASTER value.")] |
| 28 | InvalidByEaster(String), |
| 29 | #[error("`{0}` is not a valid INTERVAL value.")] |
| 30 | InvalidInterval(String), |
| 31 | #[error("`{0}` is not a valid COUNT value.")] |
| 32 | InvalidCount(String), |
| 33 | #[error("`{0}` is not a valid BYHOUR value. Expected a comma-separated list of values in range 0..=23, e.g. `1,3,4`")] |
| 34 | InvalidByHour(String), |
| 35 | #[error("`{0}` is not a valid BYWEEKNO value. Expected a comma-separated list of values in range -53..=53, e.g. `-1,30,53`")] |
| 36 | InvalidByWeekNo(String), |
| 37 | #[error("`{0}` is not a valid BYYEARDAY value. Expected a comma-separated list of values in range -366..=366, e.g. `-100,`")] |
| 38 | InvalidByYearDay(String), |
| 39 | #[error("`{0}` is not a valid BYMONTHDAY value. Expected a comma-separated list of values in range -31..=31, e.g. `-30,10`")] |
| 40 | InvalidByMonthDay(String), |
| 41 | #[error("`{0}` is not a valid BYMONTH value. Expected a comma-separated list of values in range 1..=12, e.g. `6,9,10`")] |
| 42 | InvalidByMonth(String), |
| 43 | #[error("`{0}` is not a valid BYMINUTE value. Expected a comma-separated list of values in range 0..=59, e.g. `0,15,30,45`")] |
| 44 | InvalidByMinute(String), |
| 45 | #[error("`{0}` is not a valid BYSECOND value. Expected a comma-separated list of values in range 0..=59, e.g. `0,15,30,45`")] |
| 46 | InvalidBySecond(String), |
| 47 | #[error("`{0}` is not a valid BYSETPOS value. Expected a comma-separated list of integers, e.g. `-3,1`")] |
| 48 | InvalidBySetPos(String), |
| 49 | #[error("The property `{0}` wasn't found, and it is required.")] |
| 50 | MissingProperty(String), |
| 51 | #[error( |
| 52 | "`{0}` is a malformed property parameter. Parameter should be specified as `key=value`" |
| 53 | )] |
| 54 | InvalidParameterFormat(String), |
| 55 | #[error("`{0}` is not a valid property parameter.")] |
| 56 | UnrecognizedParameter(String), |
| 57 | #[error("Found duplicate property for `{0}`, properties and parameters need to be unique.")] |
| 58 | DuplicateProperty(String), |
| 59 | #[error("Missing start date. There needs to be a unique start date which the iteration can start from.")] |
| 60 | MissingStartDate, |
| 61 | #[error("Missing date generation property. There needs to be at least one `RRULE` or `RDATE` to generate occurrences.")] |
| 62 | MissingDateGenerationRules, |
| 63 | #[error("Property parameters aren't supported for RRULE / EXRULE, found parameters: `{0}`")] |
| 64 | PropertyParametersNotSupported(String), |
| 65 | #[error( |
| 66 | "`{0}` is not a valid property name, expected one of: `RRULE,EXRULE,DTSTART,RDATE,EXDATE`" |
| 67 | )] |
| 68 | UnrecognizedPropertyName(String), |
| 69 | #[error( |
| 70 | "The value of `DTSTART` and `UNTIL` needs to match. Both need to be either a `DATE` or `DATE-TIME`" |
| 71 | )] |
| 72 | DtStartUntilMismatchValue, |
| 73 | #[error( |
| 74 | "The value of `DTSTART` was specified in local timezone, but `UNTIL` was specified with a zulu time when it had to be specified in local time as well" |
| 75 | )] |
| 76 | DtStartUntilMismatchTimezone, |
| 77 | #[error("Property parameter `{parameter}` was set to have value `{parameter_value}`, but found `{found_value}` ")] |
| 78 | ParameterValueMismatch { |
| 79 | parameter: String, |
| 80 | parameter_value: String, |
| 81 | found_value: String, |
| 82 | }, |
| 83 | } |