bma_ts/
error.rs

1use std::num::{ParseFloatError, ParseIntError, TryFromIntError};
2
3#[derive(thiserror::Error, Debug, Clone, Eq, PartialEq)]
4pub enum Error {
5    #[error("timestamp parse failed {0}")]
6    Parse(String),
7    #[error("timestamp conversion failed")]
8    ConvertChrono,
9    #[error("timestamp number conversion failed: {0}")]
10    Convert(String),
11    #[error("time went backward")]
12    TimeWentBackward,
13}
14
15macro_rules! impl_convert_err {
16    ($t: ty) => {
17        impl From<$t> for Error {
18            fn from(err: $t) -> Self {
19                Self::Convert(err.to_string())
20            }
21        }
22    };
23}
24
25impl_convert_err!(TryFromIntError);
26impl_convert_err!(ParseIntError);
27impl_convert_err!(ParseFloatError);