From f25f899e2e2c73ae9afdfdec69b8e79c2844cca5 Mon Sep 17 00:00:00 2001 From: Denis Kolodin Date: Thu, 28 Mar 2024 22:08:59 +0100 Subject: [PATCH] Derive the standard Error trait using the thiserror crate --- tree_hash/Cargo.toml | 1 + tree_hash/src/merkle_hasher.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) 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 }, }