diff --git a/docs/examples/rust/nativeexample/examples/tmq.rs b/docs/examples/rust/nativeexample/examples/tmq.rs index 49580f81b7..800b66e8fe 100644 --- a/docs/examples/rust/nativeexample/examples/tmq.rs +++ b/docs/examples/rust/nativeexample/examples/tmq.rs @@ -167,8 +167,9 @@ async fn main() -> anyhow::Result<()> { let assignments = match consumer.assignments().await{ Some(assignments) => assignments, None => { - eprintln!("Failed to get assignments."); - return Err(anyhow::anyhow!("Failed to get assignments. topic: {}, groupId: {}, clientId: {}", topic, group_id, client_id)); + let error_message = format!("Failed to get assignments. topic: {}, groupId: {}, clientId: {}", topic, group_id, client_id); + eprintln!("{}", error_message); + return Err(anyhow::anyhow!(error_message)); } }; println!("assignments: {:?}", assignments); @@ -209,8 +210,9 @@ async fn main() -> anyhow::Result<()> { let assignments = match consumer.assignments().await{ Some(assignments) => assignments, None => { - eprintln!("Failed to get assignments."); - return Err(anyhow::anyhow!("Failed to get assignments. topic: {}, groupId: {}, clientId: {}", topic, group_id, client_id)); + let error_message = format!("Failed to get assignments. topic: {}, groupId: {}, clientId: {}", topic, group_id, client_id); + eprintln!("{}", error_message); + return Err(anyhow::anyhow!(error_message)); } }; println!("After seek offset assignments: {:?}", assignments); diff --git a/docs/examples/rust/restexample/examples/tmq.rs b/docs/examples/rust/restexample/examples/tmq.rs index 86715d57cb..0a41025955 100644 --- a/docs/examples/rust/restexample/examples/tmq.rs +++ b/docs/examples/rust/restexample/examples/tmq.rs @@ -167,8 +167,9 @@ async fn main() -> anyhow::Result<()> { let assignments = match consumer.assignments().await{ Some(assignments) => assignments, None => { - eprintln!("Failed to get assignments."); - return Err(anyhow::anyhow!("Failed to get assignments. topic: {}, groupId: {}, clientId: {}", topic, group_id, client_id)); + let error_message = format!("Failed to get assignments. topic: {}, groupId: {}, clientId: {}", topic, group_id, client_id); + eprintln!("{}", error_message); + return Err(anyhow::anyhow!(error_message)); } }; println!("assignments: {:?}", assignments); @@ -209,8 +210,9 @@ async fn main() -> anyhow::Result<()> { let assignments = match consumer.assignments().await{ Some(assignments) => assignments, None => { - eprintln!("Failed to get assignments."); - return Err(anyhow::anyhow!("Failed to get assignments. topic: {}, groupId: {}, clientId: {}", topic, group_id, client_id)); + let error_message = format!("Failed to get assignments. topic: {}, groupId: {}, clientId: {}", topic, group_id, client_id); + eprintln!("{}", error_message); + return Err(anyhow::anyhow!(error_message)); } }; println!("After seek offset assignments: {:?}", assignments);