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:
committed by
Afri Schoedon
parent
2257bc8e2f
commit
14361cc7b1
@@ -69,7 +69,7 @@ pub mod blocks {
|
||||
use super::{Kind, BlockLike};
|
||||
|
||||
use engines::EthEngine;
|
||||
use error::{Error, BlockError};
|
||||
use error::{Error, ErrorKind, BlockError};
|
||||
use header::Header;
|
||||
use verification::{PreverifiedBlock, verify_block_basic, verify_block_unordered};
|
||||
|
||||
@@ -88,7 +88,7 @@ pub mod blocks {
|
||||
fn create(input: Self::Input, engine: &EthEngine) -> Result<Self::Unverified, Error> {
|
||||
match verify_block_basic(&input.header, &input.bytes, engine) {
|
||||
Ok(()) => Ok(input),
|
||||
Err(Error::Block(BlockError::TemporarilyInvalid(oob))) => {
|
||||
Err(Error(ErrorKind::Block(BlockError::TemporarilyInvalid(oob)), _)) => {
|
||||
debug!(target: "client", "Block received too early {}: {:?}", input.hash(), oob);
|
||||
Err(BlockError::TemporarilyInvalid(oob).into())
|
||||
},
|
||||
|
||||
@@ -472,17 +472,17 @@ impl<K: Kind> VerificationQueue<K> {
|
||||
let h = input.hash();
|
||||
{
|
||||
if self.processing.read().contains_key(&h) {
|
||||
return Err(ImportError::AlreadyQueued.into());
|
||||
bail!(ErrorKind::Import(ImportErrorKind::AlreadyQueued));
|
||||
}
|
||||
|
||||
let mut bad = self.verification.bad.lock();
|
||||
if bad.contains(&h) {
|
||||
return Err(ImportError::KnownBad.into());
|
||||
bail!(ErrorKind::Import(ImportErrorKind::KnownBad));
|
||||
}
|
||||
|
||||
if bad.contains(&input.parent_hash()) {
|
||||
bad.insert(h.clone());
|
||||
return Err(ImportError::KnownBad.into());
|
||||
bail!(ErrorKind::Import(ImportErrorKind::KnownBad));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,7 +502,7 @@ impl<K: Kind> VerificationQueue<K> {
|
||||
Err(err) => {
|
||||
match err {
|
||||
// Don't mark future blocks as bad.
|
||||
Error::Block(BlockError::TemporarilyInvalid(_)) => {},
|
||||
Error(ErrorKind::Block(BlockError::TemporarilyInvalid(_)), _) => {},
|
||||
_ => {
|
||||
self.verification.bad.lock().insert(h.clone());
|
||||
}
|
||||
@@ -773,7 +773,7 @@ mod tests {
|
||||
match duplicate_import {
|
||||
Err(e) => {
|
||||
match e {
|
||||
Error::Import(ImportError::AlreadyQueued) => {},
|
||||
Error(ErrorKind::Import(ImportErrorKind::AlreadyQueued), _) => {},
|
||||
_ => { panic!("must return AlreadyQueued error"); }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user