Skip to content

Commit e22a511

Browse files
authored
fix(node): classify connect_async failures as WebSocket and use Url parse error (paradigmxyz#19286)
1 parent 0c84172 commit e22a511

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

crates/node/ethstats/src/ethstats.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,9 @@ where
109109
"Attempting to connect to EthStats server at {}", self.credentials.host
110110
);
111111
let full_url = format!("ws://{}/api", self.credentials.host);
112-
let url = Url::parse(&full_url)
113-
.map_err(|e| EthStatsError::InvalidUrl(format!("Invalid URL: {full_url} - {e}")))?;
112+
let url = Url::parse(&full_url).map_err(EthStatsError::Url)?;
114113

115-
match timeout(CONNECT_TIMEOUT, connect_async(url.to_string())).await {
114+
match timeout(CONNECT_TIMEOUT, connect_async(url.as_str())).await {
116115
Ok(Ok((ws_stream, _))) => {
117116
debug!(
118117
target: "ethstats",
@@ -123,7 +122,7 @@ where
123122
self.login().await?;
124123
Ok(())
125124
}
126-
Ok(Err(e)) => Err(EthStatsError::InvalidUrl(e.to_string())),
125+
Ok(Err(e)) => Err(EthStatsError::WebSocket(e)),
127126
Err(_) => {
128127
debug!(target: "ethstats", "Connection to EthStats server timed out");
129128
Err(EthStatsError::Timeout)

0 commit comments

Comments
 (0)