use super::Client;
use crate::{Result, error::with_operation_context};
pub trait ClientErrorHandling {
fn handle_error<T>(&self, result: Result<T>, operation: &str) -> Result<T>;
fn handle_async_error<'a, T, F>(
&'a self,
f: F,
operation: &'a str,
) -> impl std::future::Future<Output = Result<T>> + Send + 'a
where
T: Send + 'a,
F: std::future::Future<Output = Result<T>> + Send + 'a;
}
impl ClientErrorHandling for Client {
fn handle_error<T>(&self, result: Result<T>, operation: &str) -> Result<T> {
with_operation_context(result, operation, "Client")
}
async fn handle_async_error<'a, T, F>(&'a self, f: F, operation: &'a str) -> Result<T>
where
T: Send + 'a,
F: std::future::Future<Output = Result<T>> + Send + 'a,
{
let result = f.await;
with_operation_context(result, operation, "Client")
}
}