php_dates/error.rs
1use thiserror::Error;
2
3/// A date pattern that cannot be used.
4#[derive(Debug, Clone, PartialEq, Eq, Error)]
5#[non_exhaustive]
6pub enum Error {
7 /// An empty pattern, a token this port does not support, or one Day.js cannot express.
8 #[error("{0}")]
9 InvalidFormat(String),
10}
11
12impl Error {
13 pub(crate) fn argument(reason: impl Into<String>) -> Self {
14 Self::InvalidFormat(reason.into())
15 }
16}
17
18/// A date pattern that failed validation.
19pub type Result<T> = std::result::Result<T, Error>;