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
@@ -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