cfx_db_errors/
statedb.rs

1// Copyright 2019 Conflux Foundation. All rights reserved.
2// Conflux is free software and distributed under GNU General Public License.
3// See http://www.gnu.org/licenses/
4
5use super::storage::Error as StorageError;
6use cfx_types::Address;
7use primitives::account::AccountError;
8use rlp::DecoderError;
9
10use thiserror::Error;
11
12#[derive(Error, Debug)]
13pub enum Error {
14    #[error(transparent)]
15    Account(#[from] AccountError),
16
17    #[error(transparent)]
18    Storage(#[from] StorageError),
19
20    #[error(transparent)]
21    Decoder(#[from] DecoderError),
22
23    #[error("incomplete database: address={0:?}")]
24    IncompleteDatabase(Address),
25
26    #[error("PoS database error, err={0:?}")]
27    PosDatabaseError(String),
28
29    #[error("{0}")]
30    Msg(String),
31}
32
33pub type Result<T> = std::result::Result<T, Error>;
34
35impl From<String> for Error {
36    fn from(e: String) -> Self { Error::Msg(e) }
37}
38
39impl From<&str> for Error {
40    fn from(e: &str) -> Self { Error::Msg(e.into()) }
41}