pub(crate) mod cache;
mod cosmos_driver;
pub(crate) mod jitter;
pub(crate) mod pipeline;
pub(crate) mod routing;
mod runtime;
pub(crate) mod transport;
pub use cosmos_driver::CosmosDriver;
pub use runtime::{CosmosDriverRuntime, CosmosDriverRuntimeBuilder};
pub(crate) fn error_chain_summary(error: &azure_core::Error) -> String {
use std::error::Error as _;
let mut parts = vec![error.to_string()];
let mut source = error.source();
while let Some(cause) = source {
let cause_str = cause.to_string();
if parts.last() != Some(&cause_str) {
parts.push(cause_str);
}
source = cause.source();
}
parts.join(": ")
}
#[cfg(test)]
mod tests {
use super::error_chain_summary;
#[test]
fn error_chain_summary_single_error() {
let error = azure_core::Error::with_message(
azure_core::error::ErrorKind::Other,
"top-level failure",
);
assert_eq!(error_chain_summary(&error), "top-level failure");
}
#[test]
fn error_chain_summary_with_source_chain() {
let inner = std::io::Error::new(std::io::ErrorKind::ConnectionReset, "socket reset");
let error = azure_core::Error::with_error(
azure_core::error::ErrorKind::Io,
inner,
"reqwest transport failed",
);
let summary = error_chain_summary(&error);
assert!(summary.contains("reqwest transport failed"));
assert!(summary.contains("socket reset"));
}
#[test]
fn error_chain_summary_deduplicates_consecutive_messages() {
let inner = azure_core::Error::with_message(
azure_core::error::ErrorKind::Other,
"connection refused",
);
let outer = azure_core::Error::with_error(
azure_core::error::ErrorKind::Connection,
inner,
"connection refused",
);
let summary = error_chain_summary(&outer);
assert_eq!(summary, "connection refused");
}
}