mirror of https://github.com/vacp2p/pmtree.git
chore: unknown errors
This commit is contained in:
parent
f777a3a457
commit
3bd24194c7
|
@ -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:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue