1use alloc::{boxed::Box, vec::Vec};
8
9#[derive(Debug, PartialEq, Eq, Clone)]
11#[cfg_attr(feature = "std", derive(thiserror::Error))]
12pub enum Error<H> {
13 #[cfg_attr(feature = "std", error("Bad format"))]
14 BadFormat,
15 #[cfg_attr(feature = "std", error("Decoding failed: {0}"))]
16 Decode(#[cfg_attr(feature = "std", source)] codec::Error),
17 #[cfg_attr(
18 feature = "std",
19 error("Recorded key ({0:x?}) access with value as found={1}, but could not confirm with trie.")
20 )]
21 InvalidRecording(Vec<u8>, bool),
22 #[cfg_attr(feature = "std", error("Trie error: {0:?}"))]
23 TrieError(Box<trie_db::TrieError<H, Self>>),
24}
25
26impl<H> From<codec::Error> for Error<H> {
27 fn from(x: codec::Error) -> Self {
28 Error::Decode(x)
29 }
30}
31
32impl<H> From<Box<trie_db::TrieError<H, Self>>> for Error<H> {
33 fn from(x: Box<trie_db::TrieError<H, Self>>) -> Self {
34 Error::TrieError(x)
35 }
36}