diff --git a/crates/rpc/rpc-types/src/eth/error.rs b/crates/rpc/rpc-types/src/eth/error.rs new file mode 100644 index 0000000000..43a70feefb --- /dev/null +++ b/crates/rpc/rpc-types/src/eth/error.rs @@ -0,0 +1,23 @@ +//! Commonly used errors for the `eth_` namespace. + +/// List of JSON-RPC error codes +#[derive(Debug, Copy, PartialEq, Eq, Clone)] +pub enum EthRpcErrorCode { + /// Failed to send transaction, See also + TransactionRejected, + /// Custom geth error code, + ExecutionError, + /// + InvalidInput, +} + +impl EthRpcErrorCode { + /// Returns the error code as `i32` + pub const fn code(&self) -> i32 { + match *self { + EthRpcErrorCode::TransactionRejected => -32003, + EthRpcErrorCode::ExecutionError => 3, + EthRpcErrorCode::InvalidInput => -32000, + } + } +} diff --git a/crates/rpc/rpc-types/src/eth/mod.rs b/crates/rpc/rpc-types/src/eth/mod.rs index 60d40e999c..3efa9750a7 100644 --- a/crates/rpc/rpc-types/src/eth/mod.rs +++ b/crates/rpc/rpc-types/src/eth/mod.rs @@ -4,6 +4,7 @@ mod account; mod block; mod call; pub mod engine; +pub mod error; mod fee; mod filter; mod index; diff --git a/crates/rpc/rpc/src/eth/error.rs b/crates/rpc/rpc/src/eth/error.rs index 49cecc7cd5..cca0dd39eb 100644 --- a/crates/rpc/rpc/src/eth/error.rs +++ b/crates/rpc/rpc/src/eth/error.rs @@ -1,37 +1,15 @@ -//! Error variants for the `eth_` namespace. +//! Implementation specific Errors for the `eth_` namespace. use crate::result::{internal_rpc_err, rpc_err}; use jsonrpsee::{core::Error as RpcError, types::error::INVALID_PARAMS_CODE}; use reth_primitives::{constants::SELECTOR_LEN, Address, U128, U256}; -use reth_rpc_types::BlockError; +use reth_rpc_types::{error::EthRpcErrorCode, BlockError}; use reth_transaction_pool::error::PoolError; use revm::primitives::{EVMError, Halt}; /// Result alias pub(crate) type EthResult = Result; -/// List of JSON-RPC error codes -#[derive(Debug, Copy, PartialEq, Eq, Clone)] -pub(crate) enum EthRpcErrorCode { - /// Failed to send transaction, See also - TransactionRejected, - /// Custom geth error code, - ExecutionError, - /// - InvalidInput, -} - -impl EthRpcErrorCode { - /// Returns the error code as `i32` - pub(crate) const fn code(&self) -> i32 { - match *self { - EthRpcErrorCode::TransactionRejected => -32003, - EthRpcErrorCode::ExecutionError => 3, - EthRpcErrorCode::InvalidInput => -32000, - } - } -} - /// Errors that can occur when interacting with the `eth_` namespace #[derive(Debug, thiserror::Error)] #[allow(missing_docs)]