ckb_indexer_sync/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//!The error type for Indexer.
use thiserror::Error;

/// A list specifying general categories of Indexer error.
#[derive(Error, Debug)]
pub enum Error {
    /// Underlying DB error
    #[error("Db error {0}")]
    DB(String),
    /// Invalid params error
    #[error("Invalid params {0}")]
    Params(String),
}

impl Error {
    /// Creates a new Indexer Params error from an string payload.
    pub fn invalid_params<S>(s: S) -> Error
    where
        S: Into<String>,
    {
        Error::Params(s.into())
    }
}

impl From<rocksdb::Error> for Error {
    fn from(e: rocksdb::Error) -> Error {
        Error::DB(e.to_string())
    }
}