diff options
author | ClementTsang <cjhtsang@uwaterloo.ca> | 2020-05-01 23:53:29 -0400 |
---|---|---|
committer | ClementTsang <cjhtsang@uwaterloo.ca> | 2020-05-02 16:01:07 -0400 |
commit | 6e81fbeebf7de91bc319b2c90cd25f18fdf288ea (patch) | |
tree | ff232af2dc4ab2705496000c779c9fd52c371ea5 /src/utils | |
parent | bb45763b39cf7a8047b0c499e6d1a2ac5f8d0847 (diff) |
change: more advanced searching and filtering
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/error.rs | 13 | ||||
-rw-r--r-- | src/utils/logging.rs | 1 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/utils/error.rs b/src/utils/error.rs index 41b3d065..22c217bc 100644 --- a/src/utils/error.rs +++ b/src/utils/error.rs @@ -1,4 +1,4 @@ -use std::result; +use std::{borrow::Cow, result}; /// A type alias for handling errors related to Bottom. pub type Result<T> = result::Result<T, BottomError>; @@ -22,6 +22,8 @@ pub enum BottomError { ConfigError(String), /// An error to represent errors with converting between data types. ConversionError(String), + /// An error to represent errors with querying. + QueryError(Cow<'static, str>), } impl std::fmt::Display for BottomError { @@ -47,6 +49,9 @@ impl std::fmt::Display for BottomError { BottomError::ConversionError(ref message) => { write!(f, "unable to convert: {}", message) } + BottomError::QueryError(ref _message) => { + write!(f, "invalid query - this should not be shown!") + } } } } @@ -98,3 +103,9 @@ impl From<std::str::Utf8Error> for BottomError { BottomError::ConversionError(err.to_string()) } } + +impl From<regex::Error> for BottomError { + fn from(err: regex::Error) -> Self { + BottomError::QueryError(err.to_string().into()) + } +} diff --git a/src/utils/logging.rs b/src/utils/logging.rs index 36619587..72822897 100644 --- a/src/utils/logging.rs +++ b/src/utils/logging.rs @@ -1,3 +1,4 @@ +#[cfg(debug_assertions)] pub fn init_logger() -> Result<(), fern::InitError> { fern::Dispatch::new() .format(|out, message, record| { |