From 3bd24194c70cce37beb4ad92cb7cf4f4c85e997f Mon Sep 17 00:00:00 2001 From: rymnc <43716372+rymnc@users.noreply.github.com> Date: Wed, 19 Apr 2023 22:46:37 +0530 Subject: [PATCH] chore: unknown errors --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 59d158b..799b8e1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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:?}"), } } }