chore: replace unreachable error variant (#10049)

This commit is contained in:
Matthias Seitz
2024-08-03 15:18:23 +02:00
committed by GitHub
parent e98acdc8d9
commit c2926de326
2 changed files with 8 additions and 7 deletions

View File

@ -378,11 +378,6 @@ pub enum RpcInvalidTransactionError {
/// Any other error
#[error("{0}")]
Other(Box<dyn ToRpcError>),
/// Unexpected [`InvalidTransaction`](revm::primitives::InvalidTransaction) error, Optimism
/// errors should not be handled on this level.
// TODO: Remove when optimism feature removed in revm
#[error("unexpected transaction error")]
UnexpectedTransactionError,
}
impl RpcInvalidTransactionError {
@ -477,13 +472,13 @@ impl From<revm::primitives::InvalidTransaction> for RpcInvalidTransactionError {
Self::AuthorizationListInvalidFields
}
#[allow(unreachable_patterns)]
_ => {
err => {
error!(target: "rpc",
?err,
"unexpected transaction error"
);
Self::UnexpectedTransactionError
Self::other(internal_rpc_err(format!("unexpected transaction error: {err}")))
}
}
}

View File

@ -7,3 +7,9 @@ pub trait ToRpcError: std::error::Error + Send + Sync + 'static {
/// Converts the error to a JSON-RPC error object.
fn to_rpc_error(&self) -> ErrorObject<'static>;
}
impl ToRpcError for ErrorObject<'static> {
fn to_rpc_error(&self) -> ErrorObject<'static> {
self.clone()
}
}