mirror of
https://github.com/ClementTsang/bottom.git
synced 2026-05-06 06:50:43 +00:00
change: more advanced searching and filtering
This commit is contained in:
+12
-1
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#[cfg(debug_assertions)]
|
||||
pub fn init_logger() -> Result<(), fern::InitError> {
|
||||
fern::Dispatch::new()
|
||||
.format(|out, message, record| {
|
||||
|
||||
Reference in New Issue
Block a user