Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use core::error::Error #11317

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crates/blockchain-tree-api/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ impl std::fmt::Debug for InsertBlockErrorData {
}
}

impl std::error::Error for InsertBlockErrorData {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
impl core::error::Error for InsertBlockErrorData {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
Some(&self.kind)
}
}
Expand Down Expand Up @@ -240,8 +240,8 @@ impl std::fmt::Debug for InsertBlockErrorDataTwo {
}
}

impl std::error::Error for InsertBlockErrorDataTwo {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
impl core::error::Error for InsertBlockErrorDataTwo {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
Some(&self.kind)
}
}
Expand Down Expand Up @@ -335,7 +335,7 @@ pub enum InsertBlockErrorKindTwo {
Provider(#[from] ProviderError),
/// Other errors.
#[error(transparent)]
Other(#[from] Box<dyn std::error::Error + Send + Sync + 'static>),
Other(#[from] Box<dyn core::error::Error + Send + Sync + 'static>),
}

impl InsertBlockErrorKindTwo {
Expand Down Expand Up @@ -425,7 +425,7 @@ pub enum InsertBlockErrorKind {
Provider(#[from] ProviderError),
/// An internal error occurred, like interacting with the database.
#[error(transparent)]
Internal(#[from] Box<dyn std::error::Error + Send + Sync>),
Internal(#[from] Box<dyn core::error::Error + Send + Sync>),
/// Canonical error.
#[error(transparent)]
Canonical(#[from] CanonicalError),
Expand Down
8 changes: 4 additions & 4 deletions crates/consensus/beacon/src/engine/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ pub enum BeaconForkChoiceUpdateError {
EngineUnavailable,
/// An internal error occurred, not necessarily related to the update.
#[error(transparent)]
Internal(Box<dyn std::error::Error + Send + Sync>),
Internal(Box<dyn core::error::Error + Send + Sync>),
}

impl BeaconForkChoiceUpdateError {
/// Create a new internal error.
pub fn internal<E: std::error::Error + Send + Sync + 'static>(e: E) -> Self {
pub fn internal<E: core::error::Error + Send + Sync + 'static>(e: E) -> Self {
Self::Internal(Box::new(e))
}
}
Expand All @@ -89,12 +89,12 @@ pub enum BeaconOnNewPayloadError {
EngineUnavailable,
/// An internal error occurred, not necessarily related to the payload.
#[error(transparent)]
Internal(Box<dyn std::error::Error + Send + Sync>),
Internal(Box<dyn core::error::Error + Send + Sync>),
}

impl BeaconOnNewPayloadError {
/// Create a new internal error.
pub fn internal<E: std::error::Error + Send + Sync + 'static>(e: E) -> Self {
pub fn internal<E: core::error::Error + Send + Sync + 'static>(e: E) -> Self {
Self::Internal(Box::new(e))
}
}
2 changes: 1 addition & 1 deletion crates/consensus/beacon/src/engine/hooks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub enum EngineHookError {
Common(#[from] RethError),
/// An internal error occurred.
#[error(transparent)]
Internal(#[from] Box<dyn std::error::Error + Send + Sync>),
Internal(#[from] Box<dyn core::error::Error + Send + Sync>),
}

/// Level of database access the hook needs for execution.
Expand Down
4 changes: 2 additions & 2 deletions crates/errors/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ pub enum RethError {

/// Any other error.
#[error(transparent)]
Other(Box<dyn std::error::Error + Send + Sync>),
Other(Box<dyn core::error::Error + Send + Sync>),
}

impl RethError {
/// Create a new `RethError` from a given error.
pub fn other<E>(error: E) -> Self
where
E: std::error::Error + Send + Sync + 'static,
E: core::error::Error + Send + Sync + 'static,
{
Self::Other(Box::new(error))
}
Expand Down
36 changes: 16 additions & 20 deletions crates/evm/execution-errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,11 @@ impl From<StateRootError> for BlockValidationError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for BlockValidationError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
impl core::error::Error for BlockValidationError {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
match self {
Self::EVM { error, .. } => std::error::Error::source(error),
Self::StateRoot(source) => std::error::Error::source(source),
Self::EVM { error, .. } => core::error::Error::source(error),
Self::StateRoot(source) => core::error::Error::source(source),
_ => Option::None,
}
}
Expand All @@ -153,7 +152,7 @@ impl BlockExecutionError {
#[cfg(feature = "std")]
pub fn other<E>(error: E) -> Self
where
E: std::error::Error + Send + Sync + 'static,
E: core::error::Error + Send + Sync + 'static,
{
Self::Internal(InternalBlockExecutionError::other(error))
}
Expand Down Expand Up @@ -185,13 +184,12 @@ impl From<ProviderError> for BlockExecutionError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for BlockExecutionError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
impl core::error::Error for BlockExecutionError {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
match self {
Self::Validation(source) => std::error::Error::source(source),
Self::Consensus(source) => std::error::Error::source(source),
Self::Internal(source) => std::error::Error::source(source),
Self::Validation(source) => core::error::Error::source(source),
Self::Consensus(source) => core::error::Error::source(source),
Self::Internal(source) => core::error::Error::source(source),
}
}
}
Expand All @@ -216,16 +214,15 @@ pub enum InternalBlockExecutionError {
#[from]
LatestBlock(ProviderError),
/// Arbitrary Block Executor Errors
#[cfg(feature = "std")]
Other(Box<dyn std::error::Error + Send + Sync>),
Other(Box<dyn core::error::Error + Send + Sync>),
}

impl InternalBlockExecutionError {
/// Create a new [`InternalBlockExecutionError::Other`] variant.
#[cfg(feature = "std")]
pub fn other<E>(error: E) -> Self
where
E: std::error::Error + Send + Sync + 'static,
E: core::error::Error + Send + Sync + 'static,
{
Self::Other(Box::new(error))
}
Expand All @@ -237,12 +234,11 @@ impl InternalBlockExecutionError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for InternalBlockExecutionError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
impl core::error::Error for InternalBlockExecutionError {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
match self {
Self::Pruning(source) => std::error::Error::source(source),
Self::LatestBlock(source) => std::error::Error::source(source),
Self::Pruning(source) => core::error::Error::source(source),
Self::LatestBlock(source) => core::error::Error::source(source),
_ => Option::None,
}
}
Expand Down
34 changes: 15 additions & 19 deletions crates/evm/execution-errors/src/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ pub enum StateRootError {
StorageRootError(StorageRootError),
}

#[cfg(feature = "std")]
impl std::error::Error for StateRootError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
impl core::error::Error for StateRootError {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
match self {
Self::Database(source) => std::error::Error::source(source),
Self::StorageRootError(source) => std::error::Error::source(source),
Self::Database(source) => core::error::Error::source(source),
Self::StorageRootError(source) => core::error::Error::source(source),
}
}
}
Expand Down Expand Up @@ -49,11 +48,10 @@ impl From<StorageRootError> for DatabaseError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for StorageRootError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
impl core::error::Error for StorageRootError {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
match self {
Self::Database(source) => std::error::Error::source(source),
Self::Database(source) => core::error::Error::source(source),
}
}
}
Expand All @@ -76,12 +74,11 @@ impl From<StateProofError> for ProviderError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for StateProofError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
impl core::error::Error for StateProofError {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
match self {
Self::Database(source) => std::error::Error::source(source),
Self::Rlp(source) => std::error::Error::source(source),
Self::Database(source) => core::error::Error::source(source),
Self::Rlp(source) => core::error::Error::source(source),
}
}
}
Expand Down Expand Up @@ -112,12 +109,11 @@ impl From<TrieWitnessError> for ProviderError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for TrieWitnessError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
impl core::error::Error for TrieWitnessError {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
match self {
Self::Proof(source) => std::error::Error::source(source),
Self::Rlp(source) => std::error::Error::source(source),
Self::Proof(source) => core::error::Error::source(source),
Self::Rlp(source) => core::error::Error::source(source),
_ => Option::None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/fs-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ pub fn write_json_file<T: Serialize>(path: &Path, obj: &T) -> Result<()> {
pub fn atomic_write_file<F, E>(file_path: &Path, write_fn: F) -> Result<()>
where
F: FnOnce(&mut File) -> std::result::Result<(), E>,
E: Into<Box<dyn std::error::Error + Send + Sync>>,
E: Into<Box<dyn core::error::Error + Send + Sync>>,
{
let mut tmp_path = file_path.to_path_buf();
tmp_path.set_extension("tmp");
Expand Down
8 changes: 4 additions & 4 deletions crates/payload/primitives/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ pub enum PayloadBuilderError {
WithdrawalsBeforeShanghai,
/// Any other payload building errors.
#[error(transparent)]
Other(Box<dyn std::error::Error + Send + Sync>),
Other(Box<dyn core::error::Error + Send + Sync>),
}

impl PayloadBuilderError {
/// Create a new error from a boxed error.
pub fn other<E>(error: E) -> Self
where
E: std::error::Error + Send + Sync + 'static,
E: core::error::Error + Send + Sync + 'static,
{
Self::Other(Box::new(error))
}
Expand Down Expand Up @@ -84,7 +84,7 @@ pub enum EngineObjectValidationError {
UnsupportedFork,
/// Another type of error that is not covered by the above variants.
#[error("Invalid params: {0}")]
InvalidParams(#[from] Box<dyn std::error::Error + Send + Sync>),
InvalidParams(#[from] Box<dyn core::error::Error + Send + Sync>),
}

/// Thrown when validating an execution payload OR payload attributes fails due to:
Expand Down Expand Up @@ -117,7 +117,7 @@ impl EngineObjectValidationError {
/// Creates an instance of the `InvalidParams` variant with the given error.
pub fn invalid_params<E>(error: E) -> Self
where
E: std::error::Error + Send + Sync + 'static,
E: core::error::Error + Send + Sync + 'static,
{
Self::InvalidParams(Box::new(error))
}
Expand Down
4 changes: 2 additions & 2 deletions crates/payload/primitives/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub trait PayloadBuilderAttributes: Send + Sync + std::fmt::Debug {
/// [`PayloadBuilderAttributes::try_new`].
type RpcPayloadAttributes;
/// The error type used in [`PayloadBuilderAttributes::try_new`].
type Error: std::error::Error;
type Error: core::error::Error;

/// Creates a new payload builder for the given parent block and the attributes.
///
Expand Down Expand Up @@ -164,7 +164,7 @@ pub trait PayloadAttributesBuilder: std::fmt::Debug + Send + Sync + 'static {
/// The payload attributes type returned by the builder.
type PayloadAttributes: PayloadAttributes;
/// The error type returned by [`PayloadAttributesBuilder::build`].
type Error: std::error::Error + Send + Sync;
type Error: core::error::Error + Send + Sync;

/// Return a new payload attribute from the builder.
fn build(&self) -> Result<Self::PayloadAttributes, Self::Error>;
Expand Down
6 changes: 2 additions & 4 deletions crates/primitives/src/transaction/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ pub enum InvalidTransactionError {
SignerAccountHasBytecode,
}

#[cfg(feature = "std")]
impl std::error::Error for InvalidTransactionError {}
impl core::error::Error for InvalidTransactionError {}

/// Represents error variants that can happen when trying to convert a transaction to
/// [`PooledTransactionsElement`](crate::PooledTransactionsElement)
Expand All @@ -87,5 +86,4 @@ pub enum TryFromRecoveredTransactionError {
BlobSidecarMissing,
}

#[cfg(feature = "std")]
impl std::error::Error for TryFromRecoveredTransactionError {}
impl core::error::Error for TryFromRecoveredTransactionError {}
2 changes: 1 addition & 1 deletion crates/rpc/ipc/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl IpcClientBuilder {
/// use jsonrpsee::{core::client::ClientT, rpc_params};
/// use reth_ipc::client::IpcClientBuilder;
///
/// # async fn run_client() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
/// # async fn run_client() -> Result<(), Box<dyn core::error::Error + Send + Sync>> {
/// let client = IpcClientBuilder::default().build("/tmp/my-uds").await?;
/// let response: String = client.request("say_hello", rpc_params![]).await?;
/// # Ok(()) }
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/ipc/src/server/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl<T, S, Fut> IpcConnDriver<T, S, Fut> {
impl<T, S> Future for IpcConnDriver<T, S, S::Future>
where
S: Service<String, Response = Option<String>> + Send + 'static,
S::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
S::Error: Into<Box<dyn core::error::Error + Send + Sync>>,
S::Future: Send + Unpin,
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
{
Expand Down
12 changes: 6 additions & 6 deletions crates/rpc/ipc/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ where
Service: Service<
String,
Response = Option<String>,
Error = Box<dyn std::error::Error + Send + Sync + 'static>,
Error = Box<dyn core::error::Error + Send + Sync + 'static>,
Future: Send + Unpin,
> + Send,
> + Send
Expand All @@ -86,7 +86,7 @@ where
/// ```
/// use jsonrpsee::RpcModule;
/// use reth_ipc::server::Builder;
/// async fn run_server() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
/// async fn run_server() -> Result<(), Box<dyn core::error::Error + Send + Sync>> {
/// let server = Builder::default().build("/tmp/my-uds".into());
/// let mut module = RpcModule::new(());
/// module.register_method("say_hello", |_, _, _| "lo")?;
Expand Down Expand Up @@ -366,7 +366,7 @@ where
/// response will be emitted via the `method_sink`.
type Response = Option<String>;

type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
type Error = Box<dyn core::error::Error + Send + Sync + 'static>;

type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;

Expand Down Expand Up @@ -441,7 +441,7 @@ fn process_connection<'b, RpcMiddleware, HttpMiddleware>(
+ Service<
String,
Response = Option<String>,
Error = Box<dyn std::error::Error + Send + Sync + 'static>,
Error = Box<dyn core::error::Error + Send + Sync + 'static>,
>,
<<HttpMiddleware as Layer<TowerServiceNoHttp<RpcMiddleware>>>::Service as Service<String>>::Future:
Send + Unpin,
Expand Down Expand Up @@ -496,7 +496,7 @@ async fn to_ipc_service<S, T>(
rx: mpsc::Receiver<String>,
) where
S: Service<String, Response = Option<String>> + Send + 'static,
S::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
S::Error: Into<Box<dyn core::error::Error + Send + Sync>>,
S::Future: Send + Unpin,
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
{
Expand Down Expand Up @@ -823,7 +823,7 @@ mod tests {
async fn pipe_from_stream_with_bounded_buffer(
pending: PendingSubscriptionSink,
stream: BroadcastStream<usize>,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
) -> Result<(), Box<dyn core::error::Error + Send + Sync>> {
let sink = pending.accept().await.unwrap();
let closed = sink.closed();

Expand Down
Loading
Loading