use error-chain in ethcore-network

This commit is contained in:
debris
2017-11-13 14:37:08 +01:00
parent b9fbe52f32
commit 3cf52dac59
28 changed files with 235 additions and 244 deletions

View File

@@ -17,10 +17,8 @@
//! Defines error types and levels of punishment to use upon
//! encountering.
use rlp::DecoderError;
use network::NetworkError;
use std::fmt;
use {rlp, network};
/// Levels of punishment.
///
@@ -41,9 +39,9 @@ pub enum Punishment {
#[derive(Debug)]
pub enum Error {
/// An RLP decoding error.
Rlp(DecoderError),
Rlp(rlp::DecoderError),
/// A network error.
Network(NetworkError),
Network(network::Error),
/// Out of credits.
NoCredits,
/// Unrecognized packet code.
@@ -92,14 +90,14 @@ impl Error {
}
}
impl From<DecoderError> for Error {
fn from(err: DecoderError) -> Self {
impl From<rlp::DecoderError> for Error {
fn from(err: rlp::DecoderError) -> Self {
Error::Rlp(err)
}
}
impl From<NetworkError> for Error {
fn from(err: NetworkError) -> Self {
impl From<network::Error> for Error {
fn from(err: network::Error) -> Self {
Error::Network(err)
}
}