Skip to content

Commit ab6376a

Browse files
committed
chore: replace derive_more with thiserror
1 parent 409af86 commit ab6376a

File tree

5 files changed

+10
-32
lines changed

5 files changed

+10
-32
lines changed

crates/rpc-types-eth/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ alloy-rlp = { workspace = true, features = ["arrayvec", "derive"] }
2727
alloy-primitives = { workspace = true, features = ["rlp", "map"] }
2828

2929
itertools.workspace = true
30-
derive_more = { workspace = true, features = ["display"] }
30+
thiserror.workspace = true
3131

3232
# serde
3333
alloy-serde = { workspace = true, optional = true }

crates/rpc-types-eth/src/block.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -275,26 +275,16 @@ impl<H: BlockHeader> HeaderResponse for Header<H> {
275275
}
276276

277277
/// Error that can occur when converting other types to blocks
278-
#[derive(Clone, Copy, Debug, derive_more::Display)]
278+
#[derive(Clone, Copy, Debug, thiserror::Error)]
279279
pub enum BlockError {
280280
/// A transaction failed sender recovery
281-
#[display("transaction failed sender recovery")]
281+
#[error("transaction failed sender recovery")]
282282
InvalidSignature,
283283
/// A raw block failed to decode
284-
#[display("failed to decode raw block {_0}")]
284+
#[error("failed to decode raw block {0}")]
285285
RlpDecodeRawBlock(alloy_rlp::Error),
286286
}
287287

288-
#[cfg(feature = "std")]
289-
impl std::error::Error for BlockError {
290-
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
291-
match self {
292-
Self::RlpDecodeRawBlock(err) => Some(err),
293-
_ => None,
294-
}
295-
}
296-
}
297-
298288
#[cfg(feature = "serde")]
299289
impl From<Block> for alloy_serde::WithOtherFields<Block> {
300290
fn from(inner: Block) -> Self {

crates/rpc-types-eth/src/filter.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ impl From<U256> for Topic {
153153
}
154154

155155
/// Represents errors that can occur when setting block filters in `FilterBlockOption`.
156-
#[derive(Debug, PartialEq, Eq, derive_more::Display)]
156+
#[derive(Debug, PartialEq, Eq, thiserror::Error)]
157157
pub enum FilterBlockError {
158158
/// Error indicating that the `from_block` is greater than the `to_block`.
159-
#[display("`from_block` ({from}) is greater than `to_block` ({to})")]
159+
#[error("`from_block` ({from}) is greater than `to_block` ({to})")]
160160
FromBlockGreaterThanToBlock {
161161
/// The starting block number, which is greater than `to`.
162162
from: u64,
@@ -165,8 +165,6 @@ pub enum FilterBlockError {
165165
},
166166
}
167167

168-
impl core::error::Error for FilterBlockError {}
169-
170168
/// Represents the target range of blocks for the filter
171169
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
172170
pub enum FilterBlockOption {

crates/rpc-types-eth/src/transaction/error.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@ use alloc::string::String;
22

33
/// Error variants when converting from [crate::Transaction] to [alloy_consensus::Signed]
44
/// transaction.
5-
#[derive(Debug, derive_more::Display)]
5+
#[derive(Debug, thiserror::Error)]
66
pub enum ConversionError {
77
/// A custom Conversion Error that doesn't fit other categories.
8-
#[display("conversion error: {_0}")]
8+
#[error("conversion error: {0}")]
99
Custom(String),
1010
}
11-
12-
#[cfg(feature = "std")]
13-
impl std::error::Error for ConversionError {
14-
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
15-
None
16-
}
17-
}

crates/rpc-types-eth/src/transaction/request.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,15 +1099,12 @@ impl From<Option<Bytes>> for TransactionInput {
10991099
}
11001100

11011101
/// Error thrown when both `data` and `input` fields are set and not equal.
1102-
#[derive(Debug, Default, derive_more::Display)]
1103-
#[display("both \"data\" and \"input\" are set and not equal. Please use \"input\" to pass transaction call data")]
1102+
#[derive(Debug, Default, thiserror::Error)]
1103+
#[error("both \"data\" and \"input\" are set and not equal. Please use \"input\" to pass transaction call data")]
11041104
#[doc(alias = "TxInputError")]
11051105
#[non_exhaustive]
11061106
pub struct TransactionInputError;
11071107

1108-
#[cfg(feature = "std")]
1109-
impl std::error::Error for TransactionInputError {}
1110-
11111108
/// Error thrown when a transaction request cannot be built into a transaction.
11121109
#[derive(Debug)]
11131110
pub struct BuildTransactionErr<T = TransactionRequest> {

0 commit comments

Comments
 (0)