use std::error::Error; use std::fmt; use redis::RedisError; use config::ConfigError; pub type LJResult = Result>; #[derive(Debug)] pub enum LJError { Config(ConfigError), RedisConnect(RedisError), HeliosDeviceMissing } impl fmt::Display for LJError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use LJError::*; match self { Config(err) => { write!(f, "unable to load config file: {err}") }, RedisConnect(err) => { write!(f, "unable to connect to redis server: {err}") }, HeliosDeviceMissing => { write!(f, "helios device not found") } } } } impl Error for LJError { fn source(&self) -> Option<&(dyn Error + 'static)> { use LJError::*; match self { RedisConnect(err) => Some(err), _ => None } } }