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::*;
|
|
|
|
|
2015-11-28 18:29:50 +01:00
|
|
|
#[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),
|
2015-11-28 18:29:50 +01:00
|
|
|
BaseData(BaseDataError),
|
|
|
|
BadSize,
|
2015-11-25 19:26:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<FromHexError> for EthcoreError {
|
|
|
|
fn from(err: FromHexError) -> EthcoreError {
|
|
|
|
EthcoreError::FromHex(err)
|
|
|
|
}
|
|
|
|
}
|
2015-11-28 18:29:50 +01:00
|
|
|
|
|
|
|
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 {
|
2015-11-28 18:29:50 +01:00
|
|
|
($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);*/
|