Skip to content

Commit b791831

Browse files
authored
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.
1 parent e367fc3 commit b791831

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

opstack/src/builder.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ impl OpStackClientBuilder {
3030
self
3131
}
3232

33-
pub fn consensus_rpc<T: IntoUrl>(mut self, consensus_rpc: T) -> Self {
34-
self.consensus_rpc = Some(consensus_rpc.into_url().unwrap());
35-
self
33+
pub fn consensus_rpc<T: IntoUrl>(mut self, consensus_rpc: T) -> Result<Self> {
34+
self.consensus_rpc = Some(consensus_rpc.into_url()?);
35+
Ok(self)
3636
}
3737

38-
pub fn execution_rpc<T: IntoUrl>(mut self, execution_rpc: T) -> Self {
39-
self.execution_rpc = Some(execution_rpc.into_url().unwrap());
40-
self
38+
pub fn execution_rpc<T: IntoUrl>(mut self, execution_rpc: T) -> Result<Self> {
39+
self.execution_rpc = Some(execution_rpc.into_url()?);
40+
Ok(self)
4141
}
4242

4343
pub fn rpc_socket(mut self, socket: SocketAddr) -> Self {

0 commit comments

Comments
 (0)