mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-11 07:25:09 -05:00
32 lines
881 B
Rust
32 lines
881 B
Rust
//! RPC errors specific to OP.
|
|
|
|
use jsonrpsee::types::ErrorObject;
|
|
use reth_rpc_eth_types::EthApiError;
|
|
use reth_rpc_server_types::result::internal_rpc_err;
|
|
use reth_rpc_types::ToRpcError;
|
|
|
|
/// Optimism specific errors, that extend [`EthApiError`].
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum OpEthApiError {
|
|
/// Thrown when calculating L1 gas fee.
|
|
#[error("failed to calculate l1 gas fee")]
|
|
L1BlockFeeError,
|
|
/// Thrown when calculating L1 gas used
|
|
#[error("failed to calculate l1 gas used")]
|
|
L1BlockGasError,
|
|
}
|
|
|
|
impl ToRpcError for OpEthApiError {
|
|
fn to_rpc_error(&self) -> ErrorObject<'static> {
|
|
match self {
|
|
Self::L1BlockFeeError | Self::L1BlockGasError => internal_rpc_err(self.to_string()),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<OpEthApiError> for EthApiError {
|
|
fn from(err: OpEthApiError) -> Self {
|
|
Self::other(err)
|
|
}
|
|
}
|