[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:
Andrew Jones
2019-05-06 14:06:20 +01:00
committed by Andronik Ordian
parent b30b54e446
commit 98b89c8e4f
23 changed files with 265 additions and 241 deletions

View File

@@ -29,7 +29,7 @@ use client::EngineClient;
use engines::{Engine, Seal, EngineError, ConstructedVerifier};
use engines::block_reward;
use engines::block_reward::{BlockRewardContract, RewardKind};
use error::{Error, ErrorKind, BlockError};
use error::{Error, BlockError};
use ethjson;
use machine::{AuxiliaryData, Call, EthereumMachine};
use hash::keccak;
@@ -585,7 +585,7 @@ fn verify_timestamp(step: &Step, header_step: u64) -> Result<(), BlockError> {
let new_oob = OutOfBounds { min, max, found };
Err(BlockError::TemporarilyInvalid(new_oob).into())
Err(BlockError::TemporarilyInvalid(new_oob.into()))
},
Ok(_) => Ok(()),
}
@@ -1342,7 +1342,7 @@ impl Engine<EthereumMachine> for AuthorityRound {
// contract itself.
let res = verify_external(header, &*validators, self.empty_steps_transition);
match res {
Err(Error(ErrorKind::Engine(EngineError::NotProposer(_)), _)) => {
Err(Error::Engine(EngineError::NotProposer(_))) => {
self.validators.report_benign(header.author(), set_number, header.number());
},
Ok(_) => {
@@ -1570,7 +1570,7 @@ mod tests {
use types::transaction::{Action, Transaction};
use engines::{Seal, Engine, EngineError, EthEngine};
use engines::validator_set::{TestSet, SimpleList};
use error::{Error, ErrorKind};
use error::Error;
use super::{AuthorityRoundParams, AuthorityRound, EmptyStep, SealedEmptyStep, calculate_score};
fn aura<F>(f: F) -> Arc<AuthorityRound> where
@@ -1883,7 +1883,7 @@ mod tests {
fn assert_insufficient_proof<T: ::std::fmt::Debug>(result: Result<T, Error>, contains: &str) {
match result {
Err(Error(ErrorKind::Engine(EngineError::InsufficientProof(ref s)), _)) =>{
Err(Error::Engine(EngineError::InsufficientProof(ref s))) =>{
assert!(s.contains(contains), "Expected {:?} to contain {:?}", s, contains);
},
e => assert!(false, "Unexpected result: {:?}", e),

View File

@@ -551,7 +551,7 @@ impl Engine<EthereumMachine> for Clique {
min: None,
max: Some(limit),
found,
}))?
}.into()))?
}
}
@@ -664,7 +664,7 @@ impl Engine<EthereumMachine> for Clique {
min: None,
max,
found,
}))?
}.into()))?
}
// Retrieve the parent state

View File

@@ -18,7 +18,7 @@
use block::*;
use engines::Engine;
use error::{Error, ErrorKind};
use error::Error;
use ethereum_types::{Address, H256};
use ethkey::{Secret, KeyPair};
use state_db::StateDB;
@@ -715,8 +715,8 @@ fn unauthorized_signer_should_not_be_able_to_sign_block() {
let tester = CliqueTester::with(3, 1, vec!['A']);
let err = tester.new_block_and_import(CliqueBlockType::Empty, &tester.genesis, None, 'B').unwrap_err();
match err.kind() {
ErrorKind::Engine(EngineError::NotAuthorized(_)) => (),
match err {
Error::Engine(EngineError::NotAuthorized(_)) => (),
_ => assert!(true == false, "Wrong error kind"),
}
}
@@ -727,8 +727,8 @@ fn signer_should_not_be_able_to_sign_two_consequtive_blocks() {
let b = tester.new_block_and_import(CliqueBlockType::Empty, &tester.genesis, None, 'A').unwrap();
let err = tester.new_block_and_import(CliqueBlockType::Empty, &b, None, 'A').unwrap_err();
match err.kind() {
ErrorKind::Engine(EngineError::CliqueTooRecentlySigned(_)) => (),
match err {
Error::Engine(EngineError::CliqueTooRecentlySigned(_)) => (),
_ => assert!(true == false, "Wrong error kind"),
}
}
@@ -744,8 +744,8 @@ fn recent_signers_should_not_reset_on_checkpoint() {
let err = tester.new_block_and_import(CliqueBlockType::Empty, &block, None, 'A').unwrap_err();
match err.kind() {
ErrorKind::Engine(EngineError::CliqueTooRecentlySigned(_)) => (),
match err {
Error::Engine(EngineError::CliqueTooRecentlySigned(_)) => (),
_ => assert!(true == false, "Wrong error kind"),
}
}