Skip to content

Commit

Permalink
Box ClientError (#878)
Browse files Browse the repository at this point in the history
cargo 1.82.0 clippy complains that the ClientError is potentially too large compared to the rest of the error types, and should be boxed

https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err
  • Loading branch information
michaeldjeffrey authored Oct 17, 2024
1 parent bea8d6e commit 0fc7d5e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions solana/src/burn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl SolanaNetwork for SolanaRpc {
self.min_priority_fee,
)
.await
.map_err(SolanaRpcError::RpcClientError)?;
.map_err(|e| SolanaRpcError::RpcClientError(Box::new(e)))?;

tracing::info!(%priority_fee);

Expand Down Expand Up @@ -277,7 +277,7 @@ impl SolanaNetwork for SolanaRpc {
transaction = %signature,
"Data credit burn failed: {err:?}"
);
Err(SolanaRpcError::RpcClientError(err))
Err(SolanaRpcError::RpcClientError(Box::new(err)))
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion solana/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub(crate) use send_with_retry;
#[derive(thiserror::Error, Debug)]
pub enum SolanaRpcError {
#[error("Solana rpc error: {0}")]
RpcClientError(#[from] ClientError),
RpcClientError(Box<ClientError>),
#[error("Anchor error: {0}")]
AnchorError(Box<helium_anchor_gen::anchor_lang::error::Error>),
#[error("Solana program error: {0}")]
Expand All @@ -57,6 +57,12 @@ impl From<helium_anchor_gen::anchor_lang::error::Error> for SolanaRpcError {
}
}

impl From<ClientError> for SolanaRpcError {
fn from(err: ClientError) -> Self {
Self::RpcClientError(Box::new(err))
}
}

pub trait GetSignature {
fn get_signature(&self) -> &Signature;
}
Expand Down
2 changes: 1 addition & 1 deletion solana/src/start_boost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl SolanaNetwork for SolanaRpc {
transaction = %signature,
"hex start boost failed: {err:?}"
);
Err(SolanaRpcError::RpcClientError(err))
Err(SolanaRpcError::RpcClientError(Box::new(err)))
}
}
}
Expand Down

0 comments on commit 0fc7d5e

Please sign in to comment.