ckb_chain_spec/
error.rs

1use ckb_error::{Error, ErrorKind, prelude::*};
2use ckb_types::packed::Byte32;
3
4/// The error type for Spec operations
5#[derive(Error, Debug, Clone, Eq, PartialEq)]
6pub enum SpecError {
7    /// The file not found
8    #[error("FileNotFound")]
9    FileNotFound(String),
10
11    /// The specified chain name is reserved.
12    #[error("ChainNameNotAllowed: {0}")]
13    ChainNameNotAllowed(String),
14
15    /// The actual calculated genesis hash is not match with provided
16    #[error("GenesisMismatch(expected: {expected}, actual: {actual})")]
17    GenesisMismatch {
18        /// The provided expected hash
19        expected: Byte32,
20        /// The actual calculated hash
21        actual: Byte32,
22    },
23}
24
25impl From<SpecError> for Error {
26    fn from(error: SpecError) -> Self {
27        ErrorKind::Spec.because(error)
28    }
29}