From b86742711428c51091d63f29bea3010c6f2389b2 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Wed, 15 May 2024 17:01:38 +0530 Subject: [PATCH] panic with message --- uplink/src/base/bridge/actions_lane.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/uplink/src/base/bridge/actions_lane.rs b/uplink/src/base/bridge/actions_lane.rs index ad807f9a..b25831fb 100644 --- a/uplink/src/base/bridge/actions_lane.rs +++ b/uplink/src/base/bridge/actions_lane.rs @@ -285,13 +285,17 @@ impl ActionsBridge { /// else marks the current action as cancelled and avoids further redirections async fn handle_cancellation(&mut self, action: Action) -> Result<(), Error> { let cancellation: Cancellation = serde_json::from_str(&action.payload)?; - if cancellation.action_id != self.current_action.as_ref().unwrap().id { + let current_action = self + .current_action + .as_ref() + .expect("Actions that are not executing can't be cancelled"); + if cancellation.action_id != current_action.id { warn!("Unexpected cancellation: {cancellation:?}"); self.forward_action_error(action, Error::UnexpectedCancellation).await; return Ok(()); } - if cancellation.name != self.current_action.as_ref().unwrap().action.name { + if cancellation.name != current_action.action.name { warn!("Unexpected cancellation: {cancellation:?}"); self.forward_action_error(action, Error::CorruptedCancellation).await; return Ok(());