diff --git a/src/conf.rs b/src/conf.rs index 02a4c15..fe5e762 100644 --- a/src/conf.rs +++ b/src/conf.rs @@ -1,6 +1,6 @@ use config::Config; use serde::{Serialize,Deserialize}; -use crate::errors::LJResult; +use crate::errors::{LJError,LJResult}; use crate::transformer; #[derive(Serialize, Deserialize, Debug, Clone)] @@ -46,7 +46,7 @@ impl Conf { .add_source(config::File::with_name(path)) .build()?; - let conf : Conf = settings.try_deserialize()?; + let conf : Conf = settings.try_deserialize().map_err(LJError::Config)?; Ok(conf) } diff --git a/src/errors.rs b/src/errors.rs index 45363e5..ff40f33 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,11 +1,13 @@ 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 } @@ -15,6 +17,10 @@ impl fmt::Display for LJError { 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}") },