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(feature = "elasticsearch")]
14 #[error("HTTP request failed: {0}")]
15 Http(#[from] reqwest::Error),
16 #[cfg(feature = "elasticsearch")]
17 #[error("Elasticsearch/OpenSearch request failed: {0}")]
18 Backend(String),
19}
20
21pub type Result<T> = std::result::Result<T, ScoutError>;