From a708900a11f829ee0c4df8c9b4950e9cc8756f20 Mon Sep 17 00:00:00 2001 From: cheme Date: Tue, 28 Apr 2020 19:42:49 +0200 Subject: [PATCH] Revert "remove deprecated description for TrieError (#85)" This reverts commit bc8a83f935ceed16232aa994bd9e156758289d1a. --- trie-db/src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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>>;