entelix_memory_pgvector/error.rs
1//! Local error type. Surfaces to callers as
2//! `entelix_core::Error::Provider` when crossing the public
3//! `VectorStore` boundary.
4
5use thiserror::Error;
6
7use entelix_core::error::Error;
8
9/// Result alias used inside `entelix-memory-pgvector`.
10pub type PgVectorStoreResult<T> = std::result::Result<T, PgVectorStoreError>;
11
12/// Errors that can surface from `PgVectorStore`.
13#[derive(Debug, Error)]
14#[non_exhaustive]
15pub enum PgVectorStoreError {
16 /// Underlying sqlx / Postgres failure.
17 #[error("postgres transport failure: {0}")]
18 Sqlx(#[from] sqlx::Error),
19
20 /// Server returned a row shape inconsistent with what the
21 /// schema migration installed. Indicates either a stale
22 /// `auto_migrate=false` deployment or external schema drift.
23 #[error("malformed row shape: {0}")]
24 Malformed(String),
25
26 /// Configuration error — invalid connection string, dimension
27 /// mismatch at build time, missing pool / pool URL.
28 #[error("configuration error: {0}")]
29 Config(String),
30
31 /// `VectorFilter` carries a JSON value the SQL projection
32 /// cannot express (e.g. a non-numeric value supplied to a
33 /// `Range` filter).
34 #[error("filter projection error: {0}")]
35 FilterProjection(String),
36}
37
38impl From<PgVectorStoreError> for Error {
39 fn from(err: PgVectorStoreError) -> Self {
40 match err {
41 PgVectorStoreError::Config(msg) | PgVectorStoreError::FilterProjection(msg) => {
42 Self::config(msg)
43 }
44 other => Self::provider_network_from(other),
45 }
46 }
47}