diff --git a/src/config/error.rs b/src/config/error.rs index a491638..f21502a 100644 --- a/src/config/error.rs +++ b/src/config/error.rs @@ -12,7 +12,9 @@ pub enum Error { NotFound(PathBuf), InvalidUtf8, TypeError{expected:LispType, got: LispType}, - BadLength, + UnexpectedEmpty, + UnknownDefinition(String), + Unknown, } @@ -52,7 +54,9 @@ impl std::fmt::Display for Error Self::NotFound(path) => write!(f, "File not found: {:?}", path), Self::InvalidUtf8 => write!(f, "Invalid UTF8 decoded string or some such"), Self::TypeError{expected, got} => write!(f, "Type mismatch: Expected {}, got {}", expected, got), - Self::BadLength => write!(f, "expected at least 1 element"), + Self::UnexpectedEmpty => write!(f, "expected a non-empty list"), + Self::UnknownDefinition(def) => write!(f, "unknown definition `{}'", def), + _ => write!(f, "unknown error") } } diff --git a/src/config/format.rs b/src/config/format.rs index ee8ab39..060a2f8 100644 --- a/src/config/format.rs +++ b/src/config/format.rs @@ -105,7 +105,7 @@ impl LispExt for Vec } else if self.len() > 0{ Ok((&self[0], &[])) } else { - Err(Error::BadLength) + Err(Error::UnexpectedEmpty) } } } diff --git a/src/config/parse.rs b/src/config/parse.rs index fac0c9c..e3126f5 100644 --- a/src/config/parse.rs +++ b/src/config/parse.rs @@ -80,7 +80,7 @@ pub async fn global(to: &mut Config, path: impl AsRef) -> Result<(), error "debug" => set_debug(to ,cdr), "allow" => mwee(to, cdr), "deny" => mwee(to, cdr), - _ => return Err(Error::Unknown), + _ => return Err(Error::UnknownDefinition(car.to_owned())), }?; } Ok(())