diff --git a/tree_hash/Cargo.toml b/tree_hash/Cargo.toml index e3a8ca9..df23b50 100644 --- a/tree_hash/Cargo.toml +++ b/tree_hash/Cargo.toml @@ -14,6 +14,7 @@ categories = ["cryptography::cryptocurrencies"] ethereum-types = "0.14.1" ethereum_hashing = "0.6.0" smallvec = "1.6.1" +thiserror = "1.0.58" [dev-dependencies] rand = "0.8.5" diff --git a/tree_hash/src/merkle_hasher.rs b/tree_hash/src/merkle_hasher.rs index c188ba5..0e35cad 100644 --- a/tree_hash/src/merkle_hasher.rs +++ b/tree_hash/src/merkle_hasher.rs @@ -2,12 +2,14 @@ use crate::{get_zero_hash, Hash256, HASHSIZE}; use ethereum_hashing::{Context, Sha256Context, HASH_LEN}; use smallvec::{smallvec, SmallVec}; use std::mem; +use thiserror::Error; type SmallVec8 = SmallVec<[T; 8]>; -#[derive(Clone, Debug, PartialEq)] +#[derive(Error, Clone, Debug, PartialEq)] pub enum Error { /// The maximum number of leaves defined by the initialization `depth` has been exceed. + #[error("The maximum number of leaves {max_leaves} has beed exceed.")] MaximumLeavesExceeded { max_leaves: usize }, }