Skip to content

Commit

Permalink
chore: upgrade thiserror (#15)
Browse files Browse the repository at this point in the history
Updated `thiserror` to version 2 and adjusted related features. Simplified conversion implementations in `Error` by using `#[from]` attribute on variants.
  • Loading branch information
shuhuiluo authored Nov 6, 2024
1 parent c37bdfb commit c52e9f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "uniswap-lens"
version = "0.5.0"
version = "0.6.0"
edition = "2021"
authors = ["Shuhui Luo <twitter.com/aureliano_law>"]
description = "A library for querying Uniswap V3 using ephemeral lens contracts."
Expand All @@ -13,11 +13,11 @@ include = ["src/**/*.rs"]
[dependencies]
alloy = { version = "0.5", features = ["contract", "rpc-types"] }
anyhow = "1"
thiserror = { version = "1.0", optional = true }
thiserror = { version = "2", default-features = false }

[features]
default = []
std = ["alloy/std", "thiserror"]
std = ["alloy/std", "thiserror/std"]

[dev-dependencies]
alloy = { version = "0.5", features = ["transport-http"] }
Expand Down
29 changes: 8 additions & 21 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
#![allow(clippy::missing_inline_in_public_items)]

use alloy::{contract::Error as ContractError, sol_types::Error as AbiError};

#[derive(Debug)]
#[cfg_attr(feature = "std", derive(thiserror::Error))]
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// An error occurred retrieving the revert data.
#[cfg_attr(feature = "std", error("Invalid revert data"))]
#[error("Invalid revert data")]
InvalidRevertData,

/// An error occurred ABI encoding or decoding.
#[cfg_attr(feature = "std", error("{0}"))]
AbiError(AbiError),
#[error("{0}")]
AbiError(#[from] AbiError),

/// An error occurred interacting with a contract over RPC.
#[cfg_attr(feature = "std", error("{0}"))]
ContractError(ContractError),
}

impl From<AbiError> for Error {
#[inline]
fn from(e: AbiError) -> Self {
Self::AbiError(e)
}
}

impl From<ContractError> for Error {
#[inline]
fn from(e: ContractError) -> Self {
Self::ContractError(e)
}
#[error("{0}")]
ContractError(#[from] ContractError),
}

0 comments on commit c52e9f8

Please sign in to comment.