1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use cosmwasm_std::StdError;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum MerkleTreeError {
    #[error(transparent)]
    Std(#[from] StdError),

    #[error("Hasher: {0}")]
    Hasher(#[from] HasherError),

    #[error("Total leaf exceed maximum leaf")]
    ExceedMaxLeaf,

    #[error("The tree is already initialized")]
    AlreadyInit,
}

#[derive(Debug, Error)]
pub enum HasherError {
    #[error("{0}")]
    Custom(String),
}

impl HasherError {
    pub fn custom(description: impl ToString) -> Self {
        Self::Custom(description.to_string())
    }
}