1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use ckb_error::{Error, ErrorKind};
use ckb_types::packed::Byte32;
use failure::Fail;

#[derive(Fail, Debug, Clone, Eq, PartialEq)]
pub enum SpecError {
    #[fail(display = "FileNotFound")]
    FileNotFound(String),

    #[fail(display = "ChainNameNotAllowed: {}", _0)]
    ChainNameNotAllowed(String),

    #[fail(
        display = "GenesisMismatch(expected: {}, actual: {})",
        expected, actual
    )]
    GenesisMismatch { expected: Byte32, actual: Byte32 },
}

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