1#[derive(Clone, Debug, PartialEq, Eq)]
2pub enum Error {
3 Trie(String),
4 RLP(rlp::DecoderError),
5 DB(String),
6 NotFound,
7 BalanceError,
8}
9
10impl std::error::Error for Error {}
11impl std::fmt::Display for Error {
12 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
13 match self {
14 Error::Trie(e) => return write!(f, "state trie: {}", e),
15 Error::RLP(e) => return write!(f, "state rlp: {}", e),
16 Error::DB(e) => return write!(f, "state db: {}", e),
17 Error::NotFound => return write!(f, "state: not found"),
18 Error::BalanceError => return write!(f, "state: balance error"),
19 }
20 }
21}
22
23impl From<cita_trie::TrieError> for Error {
24 fn from(error: cita_trie::TrieError) -> Self {
25 Error::Trie(format!("{}", error))
26 }
27}
28
29impl From<rlp::DecoderError> for Error {
30 fn from(error: rlp::DecoderError) -> Self {
31 Error::RLP(error)
32 }
33}