1use std::io;
4
5#[derive(Debug)]
6pub enum CacheError {
7 Serialize(String),
9 Deserialize(String),
11 Io(io::Error),
13}
14
15impl std::fmt::Display for CacheError {
16 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17 match self {
18 Self::Serialize(e) => write!(f, "cache serialization error: {e}"),
19 Self::Deserialize(e) => write!(f, "cache deserialization error: {e}"),
20 Self::Io(e) => write!(f, "cache I/O error: {e}"),
21 }
22 }
23}
24
25impl std::error::Error for CacheError {
26 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
27 match self {
28 Self::Io(e) => Some(e),
29 _ => None,
30 }
31 }
32}