Skip to content

Commit

Permalink
chore(workspace): Migrate back to thiserror v2 (#811)
Browse files Browse the repository at this point in the history
* chore(workspace): Migrate back to `thiserror` v2

* fmt + lint

* remove EVMError `#[from]`
  • Loading branch information
clabby authored Nov 13, 2024
1 parent cfcd461 commit 979c663
Show file tree
Hide file tree
Showing 24 changed files with 196 additions and 399 deletions.
70 changes: 37 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ sha2 = { version = "0.10.8", default-features = false }
c-kzg = { version = "1.0.3", default-features = false }
anyhow = { version = "1.0.89", default-features = false }
futures = { version = "0.3.30", default-features = false }
derive_more = { version = "1.0.0", default-features = false }
thiserror = { version = "2.0", default-features = false }

# Tracing
tracing-loki = "0.2.5"
Expand Down
2 changes: 1 addition & 1 deletion bin/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ cfg-if.workspace = true
tracing.workspace = true
serde_json.workspace = true
async-trait.workspace = true
derive_more = { workspace = true, features = ["full"] }
thiserror.workspace = true

# `tracing-subscriber` feature dependencies
tracing-subscriber = { workspace = true, optional = true, features = ["fmt"] }
Expand Down
28 changes: 12 additions & 16 deletions bin/client/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
//! Error types for the client program.
use alloc::string::{String, ToString};
use derive_more::derive::Display;
use kona_derive::errors::{PipelineError, PipelineErrorKind};
use kona_mpt::OrderedListWalkerError;
use kona_preimage::errors::PreimageOracleError;
use op_alloy_protocol::{FromBlockError, OpBlockConversionError};
use thiserror::Error;

/// Error from an oracle-backed provider.
#[derive(Display, Debug)]
#[derive(Error, Debug)]
pub enum OracleProviderError {
/// Requested block number is past the chain head.
#[display("Block number ({_0}) past chain head ({_1})")]
#[error("Block number ({0}) past chain head ({_1})")]
BlockNumberPastHead(u64, u64),
/// Preimage oracle error.
#[display("Preimage oracle error: {_0}")]
#[error("Preimage oracle error: {0}")]
Preimage(PreimageOracleError),
/// List walker error.
#[display("Trie walker error: {_0}")]
#[error("Trie walker error: {0}")]
TrieWalker(OrderedListWalkerError),
/// BlockInfo error.
#[display("From block error: {_0}")]
#[error("From block error: {0}")]
BlockInfo(FromBlockError),
/// Op Block conversion error.
#[display("Op block conversion error: {_0}")]
#[error("Op block conversion error: {0}")]
OpBlockConversion(OpBlockConversionError),
/// Error decoding or encoding RLP.
#[display("RLP error: {_0}")]
#[error("RLP error: {0}")]
Rlp(alloy_rlp::Error),
/// Slice conversion error.
#[display("Slice conversion error: {_0}")]
#[error("Slice conversion error: {0}")]
SliceConversion(core::array::TryFromSliceError),
/// Serde error.
#[display("Serde error: {_0}")]
#[error("Serde error: {0}")]
Serde(serde_json::Error),
}

impl core::error::Error for OracleProviderError {}

impl From<OracleProviderError> for PipelineErrorKind {
fn from(val: OracleProviderError) -> Self {
match val {
Expand All @@ -48,8 +46,6 @@ impl From<OracleProviderError> for PipelineErrorKind {
}

/// Error parsing a hint.
#[derive(Display, Debug)]
#[display("Hint parsing error: {_0}")]
#[derive(Error, Debug)]
#[error("Hint parsing error: {_0}")]
pub struct HintParsingError(pub String);

impl core::error::Error for HintParsingError {}
2 changes: 1 addition & 1 deletion crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ workspace = true

[dependencies]
cfg-if.workspace = true
derive_more = { workspace = true, features = ["full"] }
thiserror.workspace = true
linked_list_allocator.workspace = true
8 changes: 4 additions & 4 deletions crates/common/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! Errors for the `kona-common` crate.
use thiserror::Error;

/// An error that can occur when reading from or writing to a file descriptor.
#[derive(derive_more::Display, Debug, PartialEq, Eq)]
#[display("IO error (errno: {_0})")]
#[derive(Error, Debug, PartialEq, Eq)]
#[error("IO error (errno: {_0})")]
pub struct IOError(pub i32);

impl core::error::Error for IOError {}

/// A [Result] type for the [IOError].
pub type IOResult<T> = Result<T, IOError>;
2 changes: 1 addition & 1 deletion crates/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ tracing.workspace = true
miniz_oxide.workspace = true
async-trait.workspace = true
alloc-no-stdlib.workspace = true
derive_more = { workspace = true, features = ["full"] }
thiserror.workspace = true

# `serde` feature dependencies
serde = { workspace = true, optional = true, features = ["derive"] }
Expand Down
Loading

0 comments on commit 979c663

Please sign in to comment.