Skip to main content

redis_vl/
error.rs

1//! Error types for `redis-vl`.
2//!
3//! All fallible public APIs return `Result<T, Error>`. The [`Error`] enum
4//! wraps underlying Redis, JSON, YAML, HTTP, I/O errors as well as
5//! domain-specific schema validation and input errors.
6
7/// Result alias used throughout the crate.
8pub type Result<T> = std::result::Result<T, Error>;
9
10/// Errors returned by RedisVL operations.
11#[derive(Debug, thiserror::Error)]
12pub enum Error {
13    /// Wrapper for Redis transport errors.
14    #[error("redis error: {0}")]
15    Redis(#[from] redis::RedisError),
16    /// Wrapper for JSON serialization and parsing errors.
17    #[error("json error: {0}")]
18    Json(#[from] serde_json::Error),
19    /// Wrapper for YAML serialization and parsing errors.
20    #[error("yaml error: {0}")]
21    Yaml(#[from] serde_yaml::Error),
22    /// Wrapper for HTTP client errors.
23    #[error("http error: {0}")]
24    Http(#[from] reqwest::Error),
25    /// Wrapper for URL parsing errors.
26    #[error("url parse error: {0}")]
27    Url(#[from] url::ParseError),
28    /// Wrapper for I/O errors.
29    #[error("io error: {0}")]
30    Io(#[from] std::io::Error),
31    /// Returned when the schema is invalid.
32    #[error("schema validation error: {0}")]
33    SchemaValidation(String),
34    /// Returned when a caller provides invalid input.
35    #[error("invalid input: {0}")]
36    InvalidInput(String),
37    /// Returned when an operation depends on an unimplemented parity feature.
38    #[error("unsupported feature: {0}")]
39    Unsupported(&'static str),
40}