Skip to content

Commit

Permalink
Use if let instead of match to check Err
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrahmanElawady committed Mar 26, 2024
1 parent 319af11 commit deccc8e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,11 @@ where
tokio::time::sleep(Duration::from_millis(500)).await;
continue;
}
match self.handle_events().await {
Err(err) => {
if let Some(subxt::Error::Rpc(_)) = err.downcast_ref::<subxt::Error>() {
self.api = Self::connect(&mut self.substrate_urls).await?;
} else {
log::error!("error listening to events {}", err);
}
if let Err(err) = self.handle_events().await {
log::error!("error listening to events {}", err);
if let Some(subxt::Error::Rpc(_)) = err.downcast_ref::<subxt::Error>() {
self.api = Self::connect(&mut self.substrate_urls).await?;
}
Ok(_) => {}
}
}
}
Expand Down

0 comments on commit deccc8e

Please sign in to comment.