Skip to content

Commit 6047608

Browse files
committed
fix: Improve error handling in rest_query_state by simplifying extractor error conversion
1 parent 8ff8971 commit 6047608

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

common/src/queries/utils.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ where
2121
extractor(message)
2222
}
2323

24-
/// The outer option in the extractor return value is whether the response was handled by F
2524
pub async fn rest_query_state<T, F>(
2625
context: &Arc<Context<Message>>,
2726
topic: &str,
@@ -33,9 +32,11 @@ where
3332
T: Serialize,
3433
{
3534
let data = query_state(context, topic, request_msg, |response| {
36-
extractor(response).ok_or_else(Err(QueryError::internal_error(format!(
37-
"Unexpected response message type while calling {topic}"
38-
))))
35+
extractor(response).ok_or_else(|| {
36+
QueryError::internal_error(format!(
37+
"Unexpected response message type while calling {topic}"
38+
))
39+
})?
3940
})
4041
.await?;
4142

0 commit comments

Comments
 (0)