//! Error mapping from `qdrant_client` errors to
//! [`klieo_core::error::MemoryError`].

use klieo_core::error::MemoryError;

/// Convert any error stringified via `Display` into a
/// [`MemoryError::Store`].
///
/// `qdrant_client` exposes several error types depending on which
/// builder was used (`QdrantError`, `Status`, etc.); we collapse them
/// all into a single `Store(..)` to keep the surface stable.
pub(crate) fn store_err<E: std::fmt::Display>(e: E) -> MemoryError {
    MemoryError::Store(e.to_string())
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn store_err_routes_to_store_variant() {
        let mem = store_err("synthetic");
        assert!(matches!(mem, MemoryError::Store(_)));
    }
}
