From b7918311370b9e9e4f08fe3641ada24aeaf4e12c Mon Sep 17 00:00:00 2001 From: VolodymyrBg Date: Tue, 4 Feb 2025 19:54:15 +0200 Subject: [PATCH] refactor(builder): improve error handling in URL parsing Commit Description: Replace unwrap() calls with proper error handling in OpStackClientBuilder. This change makes the builder more robust by: - Converting consensus_rpc and execution_rpc methods to return Result - Using the ? operator for proper error propagation - Preventing potential panics from invalid URLs This improves the reliability and safety of the client builder pattern. --- opstack/src/builder.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/opstack/src/builder.rs b/opstack/src/builder.rs index b686649a..4f218bdb 100644 --- a/opstack/src/builder.rs +++ b/opstack/src/builder.rs @@ -30,14 +30,14 @@ impl OpStackClientBuilder { self } - pub fn consensus_rpc(mut self, consensus_rpc: T) -> Self { - self.consensus_rpc = Some(consensus_rpc.into_url().unwrap()); - self + pub fn consensus_rpc(mut self, consensus_rpc: T) -> Result { + self.consensus_rpc = Some(consensus_rpc.into_url()?); + Ok(self) } - pub fn execution_rpc(mut self, execution_rpc: T) -> Self { - self.execution_rpc = Some(execution_rpc.into_url().unwrap()); - self + pub fn execution_rpc(mut self, execution_rpc: T) -> Result { + self.execution_rpc = Some(execution_rpc.into_url()?); + Ok(self) } pub fn rpc_socket(mut self, socket: SocketAddr) -> Self {