Move ethcore::Error to error_chain (#8386)

* WIP

* Convert Ethcore error to use error_chain

* Use error_chain for ImportError and BlockImportError

* Fix error pattern matches for error_chain in miner

* Implement explicit From for AccountsError

* Fix pattern matches for ErrorKinds

* Handle ethcore error_chain in light client

* Explicitly define Result type to avoid shadowing

* Fix remaining Error pattern matches

* Fix tab space formatting

* Helps if the tests compile

* Fix error chain matching after merge
This commit is contained in:
Andrew Jones
2018-04-19 10:52:54 +01:00
committed by Afri Schoedon
parent 2257bc8e2f
commit 14361cc7b1
27 changed files with 249 additions and 274 deletions

View File

@@ -427,7 +427,7 @@ impl<L: AsLightClient> LightSync<L> {
// handles request dispatch, block import, state machine transitions, and timeouts.
fn maintain_sync(&self, ctx: &BasicContext) {
use ethcore::error::{BlockImportError, ImportError};
use ethcore::error::{BlockImportError, BlockImportErrorKind, ImportErrorKind};
const DRAIN_AMOUNT: usize = 128;
@@ -457,10 +457,10 @@ impl<L: AsLightClient> LightSync<L> {
for header in sink.drain(..) {
match client.queue_header(header) {
Ok(_) => {}
Err(BlockImportError::Import(ImportError::AlreadyInChain)) => {
Err(BlockImportError(BlockImportErrorKind::Import(ImportErrorKind::AlreadyInChain), _)) => {
trace!(target: "sync", "Block already in chain. Continuing.");
},
Err(BlockImportError::Import(ImportError::AlreadyQueued)) => {
Err(BlockImportError(BlockImportErrorKind::Import(ImportErrorKind::AlreadyQueued), _)) => {
trace!(target: "sync", "Block already queued. Continuing.");
},
Err(e) => {