1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum ScoutError {
5 #[error("invalid index name `{0}`: must be non-empty, contain no whitespace, contain no '/', and not start with '.'")]
6 InvalidIndexName(String),
7 #[error("invalid search result: {0}")]
8 InvalidResult(String),
9 #[error("unsupported operation: {0}")]
10 Unsupported(String),
11 #[error("JSON error: {0}")]
12 Json(#[from] serde_json::Error),
13 #[cfg(any(
14 feature = "elasticsearch",
15 feature = "meilisearch",
16 feature = "typesense",
17 feature = "algolia"
18 ))]
19 #[error("HTTP request failed: {0}")]
20 Http(#[from] reqwest::Error),
21 #[cfg(feature = "database")]
22 #[error("SQLite error: {0}")]
23 Sqlx(#[from] sqlx::Error),
24 #[cfg(any(
25 feature = "elasticsearch",
26 feature = "meilisearch",
27 feature = "typesense",
28 feature = "algolia"
29 ))]
30 #[error("backend engine request failed: {0}")]
31 Backend(String),
32}
33
34pub type Result<T> = std::result::Result<T, ScoutError>;