diff --git a/trie-db/src/lib.rs b/trie-db/src/lib.rs index d9b31b66..05b52686 100644 --- a/trie-db/src/lib.rs +++ b/trie-db/src/lib.rs @@ -121,6 +121,19 @@ impl fmt::Display for TrieError where T: MaybeDebug, E: MaybeDebug { } } +#[cfg(feature = "std")] +impl Error for TrieError where T: fmt::Debug, E: Error { + fn description(&self) -> &str { + match *self { + TrieError::InvalidStateRoot(_) => "Invalid state root", + TrieError::IncompleteDatabase(_) => "Incomplete database", + TrieError::ValueAtIncompleteKey(_, _) => "Value at incomplete key", + TrieError::DecoderError(_, ref err) => err.description(), + TrieError::InvalidHash(_, _) => "Encoded node contains invalid hash reference", + } + } +} + /// Trie result type. /// Boxed to avoid copying around extra space for the `Hasher`s `Out` on successful queries. pub type Result = crate::rstd::result::Result>>;