jiff/error/
duration.rs

1use crate::error;
2
3#[derive(Clone, Debug)]
4pub(crate) enum Error {
5    FailedNegateUnsignedDuration,
6    RangeUnsignedDuration,
7}
8
9impl From<Error> for error::Error {
10    #[cold]
11    #[inline(never)]
12    fn from(err: Error) -> error::Error {
13        error::ErrorKind::Duration(err).into()
14    }
15}
16
17impl error::IntoError for Error {
18    fn into_error(self) -> error::Error {
19        self.into()
20    }
21}
22
23impl core::fmt::Display for Error {
24    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
25        use self::Error::*;
26
27        match *self {
28            FailedNegateUnsignedDuration => {
29                f.write_str("failed to negate unsigned duration")
30            }
31            RangeUnsignedDuration => {
32                f.write_str("unsigned duration exceeds Jiff's limits")
33            }
34        }
35    }
36}