ckb_chain_spec/
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
use ckb_error::{prelude::*, Error, ErrorKind};
use ckb_types::packed::Byte32;

/// The error type for Spec operations
#[derive(Error, Debug, Clone, Eq, PartialEq)]
pub enum SpecError {
    /// The file not found
    #[error("FileNotFound")]
    FileNotFound(String),

    /// The specified chain name is reserved.
    #[error("ChainNameNotAllowed: {0}")]
    ChainNameNotAllowed(String),

    /// The actual calculated genesis hash is not match with provided
    #[error("GenesisMismatch(expected: {expected}, actual: {actual})")]
    GenesisMismatch {
        /// The provided expected hash
        expected: Byte32,
        /// The actual calculated hash
        actual: Byte32,
    },
}

impl From<SpecError> for Error {
    fn from(error: SpecError) -> Self {
        ErrorKind::Spec.because(error)
    }
}