chore: unknown errors

This commit is contained in:
rymnc 2023-04-19 22:46:37 +05:30
parent f777a3a457
commit 3bd24194c7
No known key found for this signature in database
GPG Key ID: C740033EE3F41EBD
1 changed files with 7 additions and 1 deletions

View File

@ -10,6 +10,8 @@ pub mod database;
pub mod hasher;
pub mod tree;
use std::fmt::{Debug, Display};
pub use database::*;
pub use hasher::*;
pub use tree::MerkleTree;
@ -25,12 +27,14 @@ pub enum TreeErrorKind {
MerkleTreeIsFull,
InvalidKey,
IndexOutOfBounds,
UnknownError(String),
}
#[derive(Debug)]
pub enum DatabaseErrorKind {
CannotLoadDatabase,
DatabaseExists,
UnknownError(String),
}
#[derive(Debug)]
@ -39,13 +43,15 @@ pub enum PmtreeErrorKind {
DatabaseError(DatabaseErrorKind),
/// Error in tree
TreeError(TreeErrorKind),
UnknownError(String),
}
impl std::fmt::Display for PmtreeErrorKind {
impl Display for PmtreeErrorKind {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
PmtreeErrorKind::DatabaseError(e) => write!(f, "Database error: {e:?}"),
PmtreeErrorKind::TreeError(e) => write!(f, "Tree error: {e:?}"),
PmtreeErrorKind::UnknownError(e) => write!(f, "Unknown error: {e:?}"),
}
}
}