[ethcore] remove error_chain (#10616)
* Derive Display for BlockError * Convert error_chain errors * Convert ethcore usages of errors * Fix remaining compile errors in ethcore * Fix other crates * Fix tests compilation * Implement error for Snapshot error * Remove redundant into
This commit is contained in:
committed by
Andronik Ordian
parent
b30b54e446
commit
98b89c8e4f
@@ -16,6 +16,7 @@
|
||||
|
||||
//! Snapshot-related errors.
|
||||
|
||||
use std::error;
|
||||
use std::fmt;
|
||||
|
||||
use types::ids::BlockId;
|
||||
@@ -69,6 +70,17 @@ pub enum Error {
|
||||
UnlinkedAncientBlockChain,
|
||||
}
|
||||
|
||||
impl error::Error for Error {
|
||||
fn source(&self) -> Option<&(error::Error + 'static)> {
|
||||
match self {
|
||||
Error::Trie(e) => Some(e),
|
||||
Error::Decoder(e) => Some(e),
|
||||
Error::Io(e) => Some(e),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
|
||||
@@ -30,7 +30,7 @@ use super::io::{SnapshotReader, LooseReader, SnapshotWriter, LooseWriter};
|
||||
use blockchain::{BlockChain, BlockChainDB, BlockChainDBHandler};
|
||||
use client::{BlockInfo, BlockChainClient, Client, ChainInfo, ClientIoMessage};
|
||||
use engines::EthEngine;
|
||||
use error::{Error, ErrorKind as SnapshotErrorKind};
|
||||
use error::Error;
|
||||
use snapshot::{Error as SnapshotError};
|
||||
use hash::keccak;
|
||||
use types::ids::BlockId;
|
||||
@@ -697,7 +697,7 @@ impl Service {
|
||||
let mut restoration = self.restoration.lock();
|
||||
match self.feed_chunk_with_restoration(&mut restoration, hash, chunk, is_state) {
|
||||
Ok(()) |
|
||||
Err(Error(SnapshotErrorKind::Snapshot(SnapshotError::RestorationAborted), _)) => (),
|
||||
Err(Error::Snapshot(SnapshotError::RestorationAborted)) => (),
|
||||
Err(e) => {
|
||||
warn!("Encountered error during snapshot restoration: {}", e);
|
||||
*self.restoration.lock() = None;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use tempdir::TempDir;
|
||||
use error::{Error, ErrorKind};
|
||||
use error::Error;
|
||||
|
||||
use blockchain::generator::{BlockGenerator, BlockBuilder};
|
||||
use blockchain::{BlockChain, ExtrasInsert};
|
||||
@@ -143,7 +143,7 @@ fn checks_flag() {
|
||||
let mut rebuilder = SNAPSHOT_MODE.rebuilder(chain, db.clone(), &manifest).unwrap();
|
||||
|
||||
match rebuilder.feed(&chunk, engine.as_ref(), &AtomicBool::new(false)) {
|
||||
Err(Error(ErrorKind::Snapshot(SnapshotError::RestorationAborted), _)) => {}
|
||||
Err(Error::Snapshot(SnapshotError::RestorationAborted)) => {}
|
||||
_ => panic!("Wrong result on abort flag set")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ use snapshot::{chunk_state, Error as SnapshotError, Progress, StateRebuilder, SN
|
||||
use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter};
|
||||
use super::helpers::StateProducer;
|
||||
|
||||
use error::{Error, ErrorKind};
|
||||
use error::Error;
|
||||
|
||||
use rand::{XorShiftRng, SeedableRng};
|
||||
use ethereum_types::H256;
|
||||
@@ -196,7 +196,7 @@ fn checks_flag() {
|
||||
let chunk = ::snappy::decompress(&raw).unwrap();
|
||||
|
||||
match rebuilder.feed(&chunk, &flag) {
|
||||
Err(Error(ErrorKind::Snapshot(SnapshotError::RestorationAborted), _)) => {},
|
||||
Err(Error::Snapshot(SnapshotError::RestorationAborted)) => {},
|
||||
_ => panic!("unexpected result when feeding with flag off"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user