amqp_api_client/util.rs
1use crate::error::Error;
2use serde::Deserialize;
3use tokio::sync::oneshot::Sender;
4
5/// Send the error to the replier and ALWAYS return an instance of the error through the Err.
6/// The Ok variant is never used.
7pub fn send_error_to_replier<ResponseType: for<'de> Deserialize<'de>>(
8 replier: Sender<Result<ResponseType, Error>>,
9 error: Error,
10) -> Result<(), Error> {
11 match replier.send(Err(error.clone())) {
12 Ok(_) => (),
13 Err(_) => log::error!("failed to send erroneous reply"),
14 }
15
16 Err(error)
17}