mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
implement Display trait for Error
This commit is contained in:
parent
227c9bb246
commit
a10825e91a
@ -1,3 +1,5 @@
|
|||||||
|
use std::fmt::{Display, Formatter, Result};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
Clear,
|
Clear,
|
||||||
@ -6,17 +8,15 @@ pub enum Error {
|
|||||||
Unexpected,
|
Unexpected,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error {
|
impl Display for Error {
|
||||||
pub fn to_string(&self) -> String {
|
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||||
match self {
|
match self {
|
||||||
Self::Clear => "Could not cleanup memory index".to_string(),
|
Self::Clear => write!(f, "Could not cleanup memory index"),
|
||||||
Self::NotFound(key) => {
|
Self::NotFound(key) => {
|
||||||
format!("Record `{key}` not found in memory index")
|
write!(f, "Record `{key}` not found in memory index")
|
||||||
}
|
}
|
||||||
Self::Overwrite(key) => {
|
Self::Overwrite(key) => write!(f, "Overwrite attempt for existing record `{key}`"),
|
||||||
format!("Overwrite attempt for existing record `{key}`")
|
Self::Unexpected => write!(f, "Unexpected error"),
|
||||||
}
|
|
||||||
Self::Unexpected => "Unexpected error".to_string(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user