Skip to content

Commit

Permalink
review: add thiserror to remote-provers
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiagoPittella committed Jan 14, 2025
1 parent 18e333c commit 8cdfd35
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions miden-remote-provers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ miden-objects = { workspace = true, default-features = false }
miden-tx = { workspace = true, default-features = false }
prost = { version = "0.13", default-features = false, features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }
thiserror = "2.0"

[build-dependencies]
miette = { version = "7.2", features = ["fancy"] }
Expand Down
22 changes: 8 additions & 14 deletions miden-remote-provers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ extern crate alloc;

use alloc::string::String;

use thiserror::Error;

#[cfg(feature = "tx-prover")]
pub mod generated;

Expand All @@ -16,26 +18,18 @@ pub const PROTO_MESSAGES: &str = include_str!("../proto/api.proto");
/// ERRORS
/// ===============================================================================================
#[derive(Debug)]
#[derive(Debug, Error)]
pub enum RemoteProverError {
/// Indicates that the provided gRPC server endpoint is invalid.
#[error("invalid uri {0}")]
InvalidEndpoint(String),

#[error("failed to connect to prover {0}")]
/// Indicates that the connection to the server failed.
ConnectionFailed(String),
}

impl std::fmt::Display for RemoteProverError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
RemoteProverError::InvalidEndpoint(endpoint) => {
write!(f, "Invalid endpoint: {}", endpoint)
},
RemoteProverError::ConnectionFailed(endpoint) => {
write!(f, "Failed to connect to remote prover at: {}", endpoint)
},
}
impl From<RemoteProverError> for String {
fn from(err: RemoteProverError) -> Self {
err.to_string()
}
}

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

0 comments on commit 8cdfd35

Please sign in to comment.