| 1 | #![allow(clippy::module_name_repetitions)] |
| 2 | |
| 3 | use thiserror::Error; |
| 4 | |
| 5 | pub use crate::{parser::ParseError, validator::ValidationError}; |
| 6 | |
| 7 | #[derive(Error, Debug, Clone, PartialEq, Eq)] |
| 8 | /// The error type for the rrule crate. |
| 9 | pub enum RRuleError { |
| 10 | /// Parsing error |
| 11 | #[error("RRule parsing error: {0}")] |
| 12 | ParserError(#[from] ParseError), |
| 13 | /// Validation error |
| 14 | #[error("RRule validation error: {0}")] |
| 15 | ValidationError(#[from] ValidationError), |
| 16 | /// Iterator error |
| 17 | #[error("RRule iterator error: {0}")] |
| 18 | IterError(String), |
| 19 | } |
| 20 | |
| 21 | impl RRuleError { |
| 22 | /// Create a new iterator error with the given message. |
| 23 | pub fn new_iter_err<S: AsRef<str>>(msg: S) -> Self { |
| 24 | Self::IterError(msg.as_ref().to_owned()) |
| 25 | } |
| 26 | } |