mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-08 03:01:12 -04:00
chore: add execution aborted error (#3901)
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
//! Implementation specific Errors for the `eth_` namespace.
|
||||
|
||||
use crate::result::{internal_rpc_err, invalid_params_rpc_err, rpc_err, rpc_error_with_code};
|
||||
use jsonrpsee::{core::Error as RpcError, types::ErrorObject};
|
||||
use jsonrpsee::{
|
||||
core::Error as RpcError,
|
||||
types::{error::CALL_EXECUTION_FAILED_CODE, ErrorObject},
|
||||
};
|
||||
use reth_primitives::{abi::decode_revert_reason, Address, Bytes, U256};
|
||||
use reth_revm::tracing::js::JsInspectorError;
|
||||
use reth_rpc_types::{error::EthRpcErrorCode, BlockError};
|
||||
use reth_transaction_pool::error::{InvalidPoolTransactionError, PoolError};
|
||||
use revm::primitives::{EVMError, ExecutionResult, Halt, OutOfGasError};
|
||||
use std::time::Duration;
|
||||
|
||||
/// Result alias
|
||||
pub type EthResult<T> = Result<T, EthApiError>;
|
||||
@@ -80,6 +84,9 @@ pub enum EthApiError {
|
||||
/// Error thrown when a spawned blocking task failed to deliver an anticipated response.
|
||||
#[error("internal eth error")]
|
||||
InternalEthError,
|
||||
/// Error thrown when a (tracing) call exceeded the configured timeout.
|
||||
#[error("execution aborted (timeout = {0:?})")]
|
||||
ExecutionTimedOut(Duration),
|
||||
/// Internal Error thrown by the javascript tracer
|
||||
#[error("{0}")]
|
||||
InternalJsTracerError(String),
|
||||
@@ -112,6 +119,9 @@ impl From<EthApiError> for ErrorObject<'static> {
|
||||
EthApiError::InternalJsTracerError(msg) => internal_rpc_err(msg),
|
||||
EthApiError::InvalidParams(msg) => invalid_params_rpc_err(msg),
|
||||
EthApiError::InvalidRewardPercentiles => internal_rpc_err(error.to_string()),
|
||||
err @ EthApiError::ExecutionTimedOut(_) => {
|
||||
rpc_error_with_code(CALL_EXECUTION_FAILED_CODE, err.to_string())
|
||||
}
|
||||
err @ EthApiError::InternalTracingError => internal_rpc_err(err.to_string()),
|
||||
err @ EthApiError::InternalEthError => internal_rpc_err(err.to_string()),
|
||||
}
|
||||
@@ -532,3 +542,14 @@ pub(crate) fn ensure_success(result: ExecutionResult) -> EthResult<Bytes> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn timed_out_error() {
|
||||
let err = EthApiError::ExecutionTimedOut(Duration::from_secs(10));
|
||||
assert_eq!(err.to_string(), "execution aborted (timeout = 10s)");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user