astrotime/
error.rs

1use std::error::Error as StdError;
2use std::fmt;
3
4/// Error type for the crate
5#[derive(Debug)]
6pub enum Error {
7    /// General errors
8    General(String),
9    /// Out of Range
10    RangeError,
11}
12
13impl StdError for Error {
14    fn source(&self) -> Option<&(dyn StdError + 'static)> {
15        None
16    }
17}
18
19impl fmt::Display for Error {
20    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21        match *self {
22            Error::General(ref s) => write!(f, "{}", s),
23            Error::RangeError => write!(f, "Value provided is out of range"),
24        }
25    }
26}