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