mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
implement Display trait for Error
This commit is contained in:
parent
a10825e91a
commit
a59a41f2a7
5 changed files with 33 additions and 23 deletions
|
|
@ -1,16 +1,18 @@
|
|||
use std::fmt::{Display, Formatter, Result};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
Overwrite(String),
|
||||
Unexpected,
|
||||
}
|
||||
|
||||
impl Error {
|
||||
pub fn to_string(&self) -> String {
|
||||
impl Display for Error {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
match self {
|
||||
Self::Overwrite(key) => {
|
||||
format!("Overwrite attempt for existing record `{key}`")
|
||||
write!(f, "Overwrite attempt for existing record `{key}`")
|
||||
}
|
||||
Self::Unexpected => "Unexpected error".to_string(),
|
||||
Self::Unexpected => write!(f, "Unexpected error"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue