From 448edb0cf39ef45c7afb75420694f5f6b942b5ac Mon Sep 17 00:00:00 2001 From: Omar Abdulla Date: Thu, 24 Jul 2025 15:17:36 +0300 Subject: [PATCH] Cleanup the blocking executor --- .../common/src/concepts/blocking_executor.rs | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/crates/common/src/concepts/blocking_executor.rs b/crates/common/src/concepts/blocking_executor.rs index f9364a3..b07b7fd 100644 --- a/crates/common/src/concepts/blocking_executor.rs +++ b/crates/common/src/concepts/blocking_executor.rs @@ -134,22 +134,17 @@ impl BlockingExecutor { } }; - match result.map(|result| { - *result - .downcast::() - .expect("Type mismatch in the downcast") - }) { - Ok(result) => Ok(result), + let result = match result { + Ok(result) => result, Err(error) => { - tracing::error!( - ?error, - "Failed to downcast the returned result into the expected type" - ); - anyhow::bail!( - "Failed to downcast the returned result into the expected type: {error:?}" - ) + tracing::error!(?error, "An error occurred when running the async task"); + anyhow::bail!("An error occurred when running the async task: {error:?}") } - } + }; + + Ok(*result + .downcast::() + .expect("An error occurred when downcasting into R. This is a bug")) } } /// Represents the state of the async runtime. This runtime is designed to be a singleton runtime