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 derive_more::{Display, Error, From};
use crate::status::Status;
#[derive(Debug, Display, Error, From)]
pub enum Error {
#[display(fmt = "Redis client failed to connect or run a query")]
Client(redis::RedisError),
#[display(fmt = "Limit is exceeded for a key")]
#[from(ignore)]
LimitExceeded(#[error(not(source))] Status),
#[display(fmt = "Time conversion failed")]
Time(time::error::ComponentRange),
#[display(fmt = "Generic error")]
#[from(ignore)]
Other(#[error(not(source))] String),
}
#[cfg(test)]
mod tests {
use super::*;
static_assertions::assert_impl_all! {
Error:
From<redis::RedisError>,
From<time::error::ComponentRange>,
}
static_assertions::assert_not_impl_any! {
Error:
From<String>,
From<Status>,
}
}