From cea476c6062d6bdd23b9133583d09ef1a6e241b7 Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Mon, 11 Oct 2021 10:12:59 +1100 Subject: [PATCH] More resilient loop error handling We are looping over multiple CFDs when trying to publish the CET. If we fail inside the loop then the next CFD(s) are not processed and CETs might not get published properly. This should make the code more resilient. --- daemon/src/maker_cfd.rs | 5 ++++- daemon/src/taker_cfd.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/daemon/src/maker_cfd.rs b/daemon/src/maker_cfd.rs index 2558c33..f4a138e 100644 --- a/daemon/src/maker_cfd.rs +++ b/daemon/src/maker_cfd.rs @@ -837,7 +837,10 @@ impl Actor { insert_new_cfd_state_by_order_id(cfd.order.id, cfd.state.clone(), &mut conn).await?; - self.try_cet_publication(cfd).await?; + if let Err(e) = self.try_cet_publication(cfd).await { + tracing::error!("Error when trying to publish CET: {:#}", e); + continue; + } } Ok(()) diff --git a/daemon/src/taker_cfd.rs b/daemon/src/taker_cfd.rs index cb252ee..783ecaa 100644 --- a/daemon/src/taker_cfd.rs +++ b/daemon/src/taker_cfd.rs @@ -617,7 +617,10 @@ impl Actor { insert_new_cfd_state_by_order_id(cfd.order.id, cfd.state.clone(), &mut conn).await?; - self.try_cet_publication(cfd).await?; + if let Err(e) = self.try_cet_publication(cfd).await { + tracing::error!("Error when trying to publish CET: {:#}", e); + continue; + } } Ok(())