chinese_format/gregorian/date/pattern/errors.rs
1use std::{error::Error, fmt::Display};
2
3/// Error for when a date pattern is not supported by the library.
4///
5/// ```
6/// use chinese_format::gregorian::*;
7///
8/// assert_eq!(
9/// InvalidDatePattern("dw".to_string()).to_string(),
10/// "Invalid date pattern: dw"
11/// );
12/// ```
13#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
14pub struct InvalidDatePattern(pub String);
15
16impl Display for InvalidDatePattern {
17 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18 write!(f, "Invalid date pattern: {}", self.0)
19 }
20}
21
22impl Error for InvalidDatePattern {}