openethereum/src/error.rs

42 lines
970 B
Rust
Raw Normal View History

2015-12-07 17:20:15 +01:00
//! General error types for use in ethcore.
2015-11-25 19:26:40 +01:00
use rustc_serialize::hex::*;
#[derive(Debug)]
pub enum BaseDataError {
NegativelyReferencedHash,
}
2015-11-25 19:26:40 +01:00
#[derive(Debug)]
2015-12-07 17:20:15 +01:00
/// General error type which should be capable of representing all errors in ethcore.
2015-11-25 19:26:40 +01:00
pub enum EthcoreError {
FromHex(FromHexError),
BaseData(BaseDataError),
BadSize,
2015-11-25 19:26:40 +01:00
}
impl From<FromHexError> for EthcoreError {
fn from(err: FromHexError) -> EthcoreError {
EthcoreError::FromHex(err)
}
}
impl From<BaseDataError> for EthcoreError {
fn from(err: BaseDataError) -> EthcoreError {
EthcoreError::BaseData(err)
}
}
// TODO: uncomment below once https://github.com/rust-lang/rust/issues/27336 sorted.
2015-11-28 19:28:59 +01:00
/*#![feature(concat_idents)]
macro_rules! assimilate {
($name:ident) => (
impl From<concat_idents!($name, Error)> for EthcoreError {
fn from(err: concat_idents!($name, Error)) -> EthcoreError {
EthcoreError:: $name (err)
}
}
)
}
assimilate!(FromHex);
assimilate!(BaseData);*/