fix: better call error handling (#90)

This commit is contained in:
Noah Citron 2022-11-04 20:10:24 -04:00 committed by GitHub
parent 50cdfe25ad
commit cbb96abd65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -65,7 +65,7 @@ impl<'a, R: ExecutionRpc> Evm<'a, R> {
revm::Return::InvalidOpcode => Err(eyre::eyre!("execution reverted: invalid opcode")),
revm::Return::LackOfFundForGasLimit => Err(eyre::eyre!("not enough funds")),
revm::Return::GasPriceLessThenBasefee => Err(eyre::eyre!("gas price too low")),
_ => {
revm::Return::Return => {
if let Some(err) = &self.evm.db.as_ref().unwrap().error {
return Err(eyre::eyre!(err.clone()));
}
@ -76,6 +76,7 @@ impl<'a, R: ExecutionRpc> Evm<'a, R> {
TransactOut::Call(bytes) => Ok(bytes.to_vec()),
}
}
_ => Err(eyre::eyre!("call failed")),
}
}
@ -98,7 +99,7 @@ impl<'a, R: ExecutionRpc> Evm<'a, R> {
revm::Return::InvalidOpcode => Err(eyre::eyre!("execution reverted: invalid opcode")),
revm::Return::LackOfFundForGasLimit => Err(eyre::eyre!("not enough funds")),
revm::Return::GasPriceLessThenBasefee => Err(eyre::eyre!("gas price too low")),
_ => {
revm::Return::Return => {
if let Some(err) = &self.evm.db.as_ref().unwrap().error {
return Err(eyre::eyre!(err.clone()));
}
@ -107,6 +108,7 @@ impl<'a, R: ExecutionRpc> Evm<'a, R> {
let gas_scaled = (1.10 * gas as f64) as u64;
Ok(gas_scaled)
}
_ => Err(eyre::eyre!("call failed")),
}
}