1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Debug, Clone, PartialEq, Eq)]
pub enum Error {
#[error("(full) year must be between 1 and 9999")]
DateOutOfRange,
#[error("(full) hour must be between 0 and 23")]
TimeOutOfRange,
#[error("the leading precision of the interval is too small")]
IntervalOutOfRange,
#[error("invalid number")]
InvalidNumber,
#[error("not a valid month")]
InvalidMonth,
#[error("day of month must be between 1 and last day of month")]
InvalidDay,
#[error("date not valid for month specified")]
InvalidDate,
#[error("numeric overflow")]
NumericOverflow,
#[error("divisor is equal to zero")]
DivideByZero,
#[error("Invalid format: {0}")]
InvalidFormat(String),
#[error("Failed to format: {0}")]
FormatError(String),
#[error("Failed to parse: {0}")]
ParseError(String),
}
impl From<std::fmt::Error> for Error {
#[inline]
fn from(e: std::fmt::Error) -> Self {
Error::FormatError(e.to_string())
}
}